Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Browserify: EJS

Chad Watson edited this page Jul 15, 2015 · 3 revisions

Usage

js/templates/mytemplate.ejs

<h1><%= title %></h1>
<h2><%= subtitle %></h2>
<p><%= body %></p>

js/views/mypage.js

    // get a reference to the template
var mytemplate = require('../templates/mytemplate.ejs'),
    title = 'Here\'s the title',
    subtitle = 'This is a sweet subtitle',
    body = 'Lorem ipsum...';

// call the template passing in the data
mytemplate({
  title: title,
  subtitle: subtitle,
  body: body
});
Clone this wiki locally