dynamictemplate is yet another template engine, but this time loaded with full async support and capable of being changed even after the template was rendered.
It works in browsers too.
$ npm install dynamictemplate
tpl = new Template schema:'xml', doctype:off, pretty:off, encoding:'utf-8', end:on, -> # default settings @$tag 'xml', -> @$tag 'child', "content"
This actually allows you to write real templates with asyncxml. Normally, asyncxml just gives you the ability to write asynchronous XML-generating code.
How to write tags
Maybe the main difference to some other template engines is that all the tags are asynchronous. This has the side effect that every tag has to be closed manually. As this can get a little bit anoying when you write very large templates, I added a little shortcut which invokes the end for you at the and of the child scope:
@html -> @body("content").end() @end() # is the exactly same as @$html -> @$body "content"
Just add a dollar sign (
$) in front of the tag method and it acts a little bit more synchronous again.
- Δt compiler - this compiles static HTML to template masks.
- Δt stream adapter - this lets you use node's beloved Stream to get static HTML from the templates.
- Δt jquery adapter - this lets you insert the template into dom with the help of jQuery.
- Δt list - this gives all you need to handle an ordered list of tags.
The dynamic part
TODO i couldnt find the time to build an example that's works best with dynamictemplate, so please stand by.
This is not finished yet. But please, make yourself comfortable, take a cookie and start contributing!
If you are familiar with coffeekup, you should recognize this: