View on GitHub

reading-notes

EJS

Get Started:

Install:-

    npm install ejs

Use:-

Pass EJS a template string and some data. BOOM, you’ve got some HTML.

    let ejs = require('ejs');

Browser support:-

    <script src="ejs.js"></script>
    <script>
    let people = ['geddy', 'neil', 'alex'];
    let html = ejs.render('<%= people.join(", "); %>', {people: people});
    </script>

Options:-

Includes:-

Includes are relative to the template with the include call. (This requires the ‘filename’ option.) For example if you have “./views/users.ejs” and “./views/user/show.ejs” you would use <%- include(‘user/show’); %>.