jade-runtime
The runtime components for the jade templating language
Installation
npm install jade-runtime
Usage
You can call runtime methods directly using runtime.method
. This is particularly useful when compiling to deal with things that are already known at compile time.
var runtime = ; ;
You can also build a string with a given list of functions available as jade_method
by calling build(arrayOfMethods)
. This is useful for inlining runtime functions within the compiled templates.
var build = ;var src = ; var attr = Function'' src + ';return jade_attr;';;
When testing code compiled for the browser in Node.js, it is necessary to make the runtime available. To do so, one can use require('jade-runtime/wrap')
:
var jade = ;var wrap = ; var jadeSrc = 'p= content';// By default compileClient automatically embeds the needed runtime functions,// rendering this module useless.var compiledCode = jade;//=> 'function template (locals) { ... jade.escape() ... }' var templateFunc = ;;//=> '<p>Hey!</p>' // Change template function name to 'heyTemplate'compiledCode = jade;//=> 'function heyTemplate (locals) { ... }' templateFunc = ;;//=> '<p>Hey!</p>'
License
MIT