Skip to content

Instantly share code, notes, and snippets.

@abstractvector
Created July 14, 2012 18:36
Show Gist options
  • Save abstractvector/3112573 to your computer and use it in GitHub Desktop.
Save abstractvector/3112573 to your computer and use it in GitHub Desktop.
Template: template.html
<div>{{> partials/nested-list.html}}</div>
Partial: partials/nested-list.html
<ul>
{{#list}}
<li>
<a href="{{url}}">{{title}}</a>
{{> partials/nested-list.html}}
</li>
{{/list}}
</ul>
node.js (with Hogan.js):
var list = [
{
title: 'Google',
url: 'http://www.google.com',
list: [
{
title: 'Google UK',
url: 'http://www.google.co.uk',
list: []
},
{
title: 'Google US',
url: 'http://www.google.com',
list: []
}
]
},
{
title: 'Yahoo',
url: 'http://www.yahoo.com',
list: []
}
];
res.render(
'template.html',
{
locals: { list: list },
partials: app.set('partials') // this is where they're stored, and they do work correctly
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment