template2module-loader
a webpack loader based on template2module, supports multiple template engines, generates high performance code.
configuration
module: loaders: test: /\.?$/ loader: 'template2module-loader' exclude: /demo/ query: engine: 'underscore' format: 'commonjs' outerScopeVars: 'translate' '_' preOuterScope: 'var translate = require("zero-text/i18n").translate;' 'var _ = require("underscore");'
this configuration will transform template file as followed into a module like this:
template file content
I am <%=name%><%if(man){%> and I like playing <%=man.game%><%}%>.My favorite animates are<% _.each(animates, function(animate){ %> <% if (animate.type !== invisibleType ){ %> <%=animate.name%> <% } %><% }); %>etc.
module file content