MUPLATE
Muplates are templates that are full javascript. Yes, yes, separation of concerns, logic shouldn't be in templates, yadda yadda. I don't give a damn. If you do, there are many other templates engines available. If, like me, you think "JS all the way FTW", then you might have found paradise.
Muplate uses Virtual-Dom behind the scenes.
This is experimental, probably very buggy, and not fit for use in production.
Usage
npm install -s muplate
//templates/main.js{ ;}
//index.jsvar Muplate = ;var mu = ;mu;//or async:mu;
Things of interest
- If you don't use 'exports = ' or 'module.exports =' in your template, it will be automatically prepended to your first line
- You can use
var xxx = arguments
to automatically transform arguments into an array (in a non-leaky way). - Templates are pre-processed with doT, so you can use this to generate macros and do some meta-coding (but default delimiters are
<%
and%>
instead of the default{{
and}}
). - Templates are cached on the
mu
object, so subsequent calls to the same template will not load it again. If you want a different set of templates, create a new muplate object by callingMuplate()
again. - If you set a
css
property to any object with a valid identifier (class name or id), it will be extracted and available on themu
object by callingmu.css()
;