templates
Version:
System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.
45 lines (38 loc) • 1.17 kB
JavaScript
'use strict';
var utils = require('../utils');
/**
* Common properties that need to be initialized on the templates instance,
* and/or other instances.
*/
module.exports = function(app) {
app.cache = {};
app.cache.data = {};
app.cache.context = {};
// prime `_`
if (!app._) utils.define(app, '_', {});
app._.helpers = {
async: {},
sync: {}
};
app.viewTypes = {
layout: [],
partial: [],
renderable: []
};
app.define('templatesError', {
compile: {
callback: 'is sync and does not take a callback function',
engine: 'cannot find an engine for: %s',
method: 'expects engines to have a compile method'
},
render: {
callback: 'is async and expects a callback function',
engine: 'cannot find an engine for: %s',
method: 'expects engines to have a render method'
},
layouts: {
notfound: 'layout "%s" was defined on view "%s" but cannot be not found (common causes are incorrect glob patterns, renameKey function modifying the key, and typos in search pattern)',
registered: 'layout "%s" was defined on view "%s" but no layouts are registered'
}
});
};