handlebars-load-tree
v0.10.3
Published
Load handlebars templates and partials from a directory, recursively.
Downloads
59
Readme
Handlebars Load Tree
The handlebars tree loader exposes one function which will walk a directory tree, recursively, compiling handlebars templates.
var path = require('path');
var Handlebars = require('handlebars');
var handlebarsLoadTree = require('handlebars-load-tree');
var views = handlebarsLoadTree(Handlebars, path.join(__dirname, 'spec', 'fixtures'));
var locals = {
title: 'Titles are Nice',
items: [
{
text: 'Buy Milk'
},
{
text: 'Pick up Prescription'
},
{
text: 'Read PDF'
}
]
};
views.call('index_vanilla', locals).then(console.log);
Handlebars-Layouts
This plugin also works with handlebars-layouts as handlebars-layouts modified
the Handlebars instance. Load handlebars-layouts normally and pass the modified
Handlebars to handlebarsLoadTree
.
var path = require('path');
var Handlebars = require('handlebars');
require('handlebars-layouts')(Handlebars);
var handlebarsLoadTree = require('handlebars-load-tree');
var views = handlebarsLoadTree(Handlebars, path.join(__dirname, 'spec', 'fixtures'));
var locals = {
title: 'Titles are Nice',
items: [
{
text: 'Buy Milk'
},
{
text: 'Pick up Prescription'
},
{
text: 'Read PDF'
}
]
};
views.call('index', locals).then(console.log);