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.
| { | 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.
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.
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.
// 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')