pugjs / pug-runtime

The runtime for the Pug compiler
MIT License
10 stars 6 forks source link

Add a wrap module #18

Closed TimothyGu closed 9 years ago

TimothyGu commented 9 years ago

Allows one to do:

var jadeSrc = 'p= body';
// By default compileClient automatically embeds the needed runtime
functions,
// rendering this module useless.
var compiledCode = jade.compileClient(jadeSrc, {
  externalRuntime: true
});
//=> 'function template (locals) { ... jade.escape() ... }'

var templateFunc = wrap(compiledCode);
templateFunc({body: 'Hey!'});
//=> '<p>Hey!</p>'

There are plenty of places where this can be used:

alubbe commented 9 years ago

Code LGTM. I was thinking about the p= body example. I found it somewhat confusing because body is also an HTML tag. Could we change it to something else, maybe h1 Hello #{name}?