Skip to content

tswaters/webmake-ejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webmake-ejs

Require EJS files with Webmake

Install

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

Usage

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

Programmatically

test-ejs-file.ejs

<% if (names.length) { %>
<ul>
  <% names.forEach(function(name){ %>
    <li><%= name %></li>
  <% }) %>
</ul>
<% } %>

app.js

var names = ['loki', 'tobi', 'jane'];
var html = require('./test-ejs-file')({
  'names': names
});
document.body.innerHTML = html;

run it

webmake --ext=ejs app.js bundle.js

Output

<ul>
    <li>loki</li>
    <li>tobi</li>
    <li>jane</li>
</ul>

About

Require EJS files with Webmake

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published