Pure.js

Pure.js is a JavaScript templating engine that takes the concept of logic-less templates to an even greater extreme than Mustache and Handlebars do. Pure.js uses no special template expression syntax that has to be interpolated before rendering. Instead, it uses only pure HTML tags and CSS selectors, combined with JSON data, to render values in the DOM. In this way, Pure.js uses entirely logic-less views because there is no template markup in which to include any logic.

Markup

Using plain HTML, a simple Pure.js template can be constructed like this:

<p class="my-template"> 
    Hello, my name is <span></span>. 
</p> 

The empty <span> element is where you might add data for a particular template, but you can use any HTML tag.

var data = { name: 'Udis ...

Get Mastering JavaScript Single Page Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.