Require EJS files with Webmake
To use this extension, install it aside of Webmake:
$ npm install webmake-ejs
If you use global installation of Webmake, then extension also needs to be installed globally:
$ npm install -g webmake-ejs
When running Webmake, ask webmake to use it:
$ webmake --ext=ejs program.js bundle.js
Same way when Webmake is used programmatically:
webmake(inputPath, { ext: 'ejs' }, cb);
webmake-ejs can be used with any other Webmake extension, e.g.:
$ webmake --ext=ejs --ext=otherext program.js bundle.js
<% if (names.length) { %>
<ul>
<% names.forEach(function(name){ %>
<li><%= name %></li>
<% }) %>
</ul>
<% } %>
var names = ['loki', 'tobi', 'jane'];
var html = require('./test-ejs-file')({
'names': names
});
document.body.innerHTML = html;
webmake --ext=ejs app.js bundle.js
<ul>
<li>loki</li>
<li>tobi</li>
<li>jane</li>
</ul>