Underscore.js
The Underscore.js library is well known for its useful JavaScript functional programming helpers and utility methods. One of those utility methods is _.template(). This method is used to compile strings with expressions into functions that replace those expressions with dynamic values.
Underscore.js template syntax delimiters resemble those of the ERB, or Embedded Ruby template syntax, with an equals sign following the opening tag:
<p>Hello, <%= name %>.</p>
An Underscore.js template expression used within HTML looks like the preceding example. The variable name would be dynamically passed in to the compiled function for this template.
The _.template() method can also be used to parse and execute arbitrary JavaScript code within a template. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access