GithubHelp home page GithubHelp logo

stpl's Introduction

stpl

really lightweight and simple javascript template system Build Status

##supported syntax:

  • single variable parameters: {{varname}}
  • escaped single variable parameters: {{{varname}}}
  • if syntax: {{varname?}}varname as a value{{?varname}}
  • if not syntax {{varname!?}}varname as a value{{?varname}}
  • loop through each elements {{#elements}}<li>{{propname}}</li>{{/elements}}
    • even using alias {{#elements as elmt}}<li>{{elmt.propname}}</li>{{/elements}}
  • support dotted notation {{childs.length}}
    • even back reference ``{{../propName}}
  • can even include sub templates {{>subTemplateName}}
  • filtering properties dynamicly {{firstname|ucFirst}}
    • including builtin filters: empty, jsonEncode, lowerCase, ucFirst, upperCase, nl2br

methods:

  • stpl.registerScriptTag(DOMelment scriptTag,[String name (default to rel attribute value)]) register the content of a script type="text/stpl" as a template string
  • stpl.registerString(String name, String templateString) register a string as a template
  • stpl.registerFilter(String name,Function filter) register a filter any global function can be used as a filter without being previously registered
  • stpl.preload() preload all script tags with type="text/stpl" as template string using their rel attribute as name.
  • stpl.renderString(String templateString,Object datas,Object context) render the given template string using given datas. A context may be passed ans will be used for accessing parent properties for example
  • stpl(String templateName, Object datas) will render previously registered template string with given datas

stpl's People

Contributors

malko avatar

Stargazers

Maxim Kostjukevich avatar Pavel Belousov avatar Vladimir Starkov avatar Adrien Gibrat avatar

Watchers

 avatar James Cloos avatar Pavel Belousov avatar  avatar

Forkers

fossabot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.