<% Embedded JavaScript %>

Download EJS
Developer 1.0 Production (9.8KB)


EJS cleans the HTML out of your JavaScript with client side templates. After EJS gets its rubber gloves on dirty code, you'll feel organized and uncluttered.

Try it!

The Data.

{ title: 'Cleaning Supplies'
supplies: ['mop', 'broom', 'duster'] }

EJS combines data and a template to produce HTML. Here, our example data has a title and a list of supplies.

The Template.

Type here

Like ERB, JavaScript between <% %> is executed. JavaScript between <%= %> adds HTML to the result.

Type HTML or JavaScript in the template
Watch as your changes update the result.

Try typing these suggestions:
Insert "<h1> <%= title %> </h1>"

The Result.

The result is shown here

The result on the right is the output of the template processed with the data.

If you make a mistake, EJS provides the line number and a message for easier debugging.

Use it.


Maintained By.



// load a template file, then render it with data
html = new EJS({url: '/template.ejs'}).render(data)

// update element 'todo' with the result of a  
// template rendered with data from a JSON request
new EJS({url:'/todo.ejs'}).update('todo','/todo.json')