Handlebars example

This is the same template but for Handlebars. The template is not pure HTML and is not suitable to design in the browser with.

{{title}}

Hello from {{name}}!

{{content}}

This should link to Aral’s homepage.

This should link to Ind.ie

This should be Aral’s headshot:

Friends and their skills

{{#if friends}}
    {{#each friends}}
  • {{name}} knows {{skills}}.

  • {{/each}}
{{else}}

No friends found.

{{/if}}

HTML

<h1>{{title}}</h1>
<p>Hello from {{name}}!<p>

<p>{{content}}</p>

<p><a href='{{newURL}}'>This should link to Aral&rsquo;s homepage.</a></p>

<p><a href='http://{{correctURLFragment}}.com'>This should link to Ind.ie.</a></p>

<p>This should be Aral&rsquo;s headshot:</p>

<img src='{{aralImageURL}}'>

<h2>Friends and their skills</h2>

{{#if friends}}
<ul class='friends-list'>
  {{#each friends}}
  <li>
    <p>{{name}} knows {{skills}}.</p>
  </li>
  {{/each}}
</ul>
{{else}}
<p class='no-friends-warning'>No friends found.</p>
{{/if}}

Data

data =
  title: 'Express 3‐Handlebars sample'
  name: 'Express 3‐Handlebars'
  content: 'This is a simple example to demonstrate Express 3‐Handlebars'
  newURL: 'http://aralbalkan.com'
  correctURLFragment: 'ind'
  aralImageURL: 'http://aralbalkan.com/images/aral.jpg'
  friends:
  [
    {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) ->
  response.render 'simple', data