diff options
Diffstat (limited to 'lib/template/index.js')
-rw-r--r-- | lib/template/index.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/template/index.js b/lib/template/index.js index 833ff76..a3021e6 100644 --- a/lib/template/index.js +++ b/lib/template/index.js @@ -7,6 +7,7 @@ var Promise = require('../utils/promise'); var error = require('../utils/error'); var gitbook = require('../gitbook'); var defaultBlocks = require('./blocks'); +var Loader = require('./loader'); // Return extension name for a specific block function blockExtName(name) { @@ -23,6 +24,10 @@ function TemplateEngine(book) { this.book = book; this.log = book.log; + // Create file loader + this.loader = new Loader(this); + + // Create nunjucks instance this.env = new nunjucks.Environment( this.loader, { @@ -57,6 +62,14 @@ function TemplateEngine(book) { this.addBlocks(defaultBlocks); } +// Interpolate a string content to replace shortcuts according to the filetype +TemplateEngine.prototype.interpolate = function(filepath, source) { + var parser = parsers.get(path.extname(filepath)); + var type = parser? parser.name : null; + + return this.applyShortcuts(type, source); +}; + // Add a new custom filter TemplateEngine.prototype.addFilter = function(filterName, func) { try { |