blob: 810c41e03eb85c599c1f940472ebed537c1ab95b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
var Immutable = require('immutable');
var TemplateEngine = require('../models/templateEngine');
/**
Create template engine for an output.
It adds default filters/blocks, then add the ones from plugins
@param {Output} output
@return {TemplateEngine}
*/
function createTemplateEngine(output) {
var plugins = output.getPlugins();
var filters = plugins
.reduce(function(result, plugin) {
return result.merge(plugin.getFilters());
}, Immutable.Map());
var blocks = plugins
.map(function(plugin) {
return plugin.getBlocks();
})
.flatten();
return new TemplateEngine({
filters: filters,
blocks: blocks
});
}
module.exports = createTemplateEngine;
|