https://github.com/mdb/selleck.js
A mustachioed templating library
https://github.com/mdb/selleck.js
Last synced: 8 months ago
JSON representation
A mustachioed templating library
- Host: GitHub
- URL: https://github.com/mdb/selleck.js
- Owner: mdb
- License: mit
- Created: 2011-02-21T00:14:07.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2011-03-18T02:13:26.000Z (about 15 years ago)
- Last Synced: 2025-04-17T16:55:31.091Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 454 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
Selleck is yet another mustachioed templating library. This (selleck.js)
is the JavaScript version.
Installation
------------
Coming soon.
Usage
-----
Selleck keeps templates readable by limiting tags to statements ("for" and
"if"), variables, and partials. A "for" tag loops over variables in an array:
{for variable in array}
{variable}
{/for}
An "if" tag only displays a section of the template for a truthy variable, or
the inverse:
{if variable}
{variable}
{/if}
{if not variable}
No variable!
{/if}
As you can see, "for" and "if" sections are closed by a corresponding tag with
a leading slash.
Variable tags may use dot notation. If the variable is a function, its return
value will be used:
{object.variable}
A partial tag begins with a greater-than sign. It is replaced by a
sub-template at that spot in the template:
{>partial}
Templates are rendered as follows, where "template" is a string and "context"
and "partials" are objects:
var rendered = selleck.render(template, context, partials);
Any tag is escaped from rendering by prepending a backslash:
\{variable}
See the test directory for full usage examples.
Philosophy
----------
The limits of Selleck's templates (no filters or complex tags) encourage a
careful and thorough preparation of the context. The retrieval, manipulation,
and conversion of data for display is kept separate from the presentation.
Selleck is influenced by these fine projects:
http://github.com/janl/mustache.js
http://github.com/akdubya/dustjs
http://github.com/andychu/json-template
http://docs.djangoproject.com/en/dev/ref/templates/