Rendered template

This is the template as rendered by Set, along with the Set source, showing the HTML, the data object, and the Express 3 router in node.js. All the other examples render to exactly the same output.

Simple Set Demo

Hello from Set!

This is a simple example to demonstrate Set, a templating engine for Express (node.js) and client‐side JavaScript.

This should link to Aral’s homepage.

This should link to

This should be Aral’s headshot:

Friends and their skills

  • Laura knows design, development, illustration, speaking.

  • Jo knows operations, cognitive psychology, sports coaching.

  • Osky knows begging for food, looking cute, occasionally howling.

No friends found.


<h1 data-set-text='title'>A placeholder title</h1>

<p>Hello from <span data-set-text='name'>name of the templating engine</span>!<p>

<!-- Text substitution -->
<p data-set-text='content'>This paragraph is a placeholder.</p>

<!-- Attribute substitution -->
<p><a data-set-attribute='href newURL' href='/'>This should link to Aral’s homepage.</a></p>

<!-- Custom Formatter -->
<p><a data-set-attribute='href correctURLFragment fullURL' href=''>This should link to</a></p>

<p>This should be Aral’s headshot:</p>

<!-- Placeholder image -->
<img data-set-attribute='src aralImageURL' src=''>

<h2>Friends and their skills</h2>

<!-- Conditional -->
<ul data-set-if='friends'>
  <!-- Repeater -->
  <li data-set-repeat='friend friends'>
    <p><span data-set-text=''>Name</span> knows <span data-set-text='friend.skills'>skills</span>.</p>

  <!-- Dummy data -->
  <li data-set-dummy>
    <p>Some sample content.</p>
  <li data-set-dummy>
    <p>That could help when styling the page.</p>

<!-- Conditional -->
<p data-set-if='not:friends'>No friends found.</p>


data =
  title: 'Set sample'
  name: 'Set'
  content: 'This is a simple example to demonstrate Set, a templating engine for Express (node.js) and client‐side JavaScript.'
  newURL: ''
  correctURLFragment: 'ind'
  aralImageURL: ''
    {name: 'Laura', skills: 'design, development, illustration, speaking'},
    {name: 'Jo', skills: 'operations, cognitive psychology, sports coaching'},
    {name: 'Osky', skills: 'begging for food, looking cute, occasionally howling'}

Express 3 router (node.js)

exports.route = (request, response) ->
# Custom formatter
data.__set = {
    fullURL: (value) ->
      return 'http://' + value + '.com'
response.render 'simple', data