jadeite
Jadeite is a Jade-like template language, and it's actually valid JavaScript.
Feedbacks are welcome!
Features
- Variable substitution
- Compiled template (fast!)
- Conditionals
Why?
- Because it's fun!
Install
Unstable, use at your own risk
This package uses the (old) Proxy API,
so you need v0.11 node (and --harmony
flags) or a harmony enabled browser..
With npm
do
$ npm install jadeite
Usage
Write your template function:
{ withmagic // `with` is needed if you want to omit property access return html head title 'Welcome on my Awesome site!' //very named arguments :o body h1 // wow, so dynamic attributes! linkText // such dynamic content // empty tag, function call needed, or it will be substituted with the `input` variable 'true!' ; }
Compile it, and it's ready to use:
var jadeite = ;var template = ; console;// <html><head><title>Welcome on my Awesome site!</title><script type="text/javascript" src="/bundle.js" /></head><body><h1><a href="/home">Hello world!</a><input /></h1></body></html>
API
jadeite(fn)
fn
is a template function that accepts one parameter, like in the example. It return the compiled template, the example (myTemplate
) will compile to this:
{ var a = ; a; a; a; a; a; ifdatacond a; a; return a;}
Plans
- Loops:
each(item in items)(li(item))
jadeite < input.js
command- Less parens :)))
- Unicorns
License
MIT