Allow use of .njk extension for template files.

This commit is contained in:
Michael Teeuw 2017-10-18 13:49:03 +02:00
parent c75662e720
commit f4d5996a88
3 changed files with 6 additions and 3 deletions

View File

@ -86,7 +86,7 @@ var Module = Class.extend({
var templateData = this.getTemplateData();
// Check to see if we need to render a template string or a file.
if (/^.*(\.html)$/.test(template)) {
if (/^.*((\.html)|(\.njk))$/.test(template)) {
// the template is a filename
this.nunjucksEnvironment().render(template, templateData, function (err, res) {
if (err) {
@ -170,7 +170,10 @@ var Module = Class.extend({
var self = this;
this._nunjucksEnvironment = new nunjucks.Environment(new nunjucks.WebLoader(this.file(""), {async: true}));
this._nunjucksEnvironment = new nunjucks.Environment(new nunjucks.WebLoader(this.file(""), {async: true}), {
trimBlocks: true,
lstripBlocks: true
});
this._nunjucksEnvironment.addFilter("translate", function(str) {
return self.translate(str)
});

View File

@ -15,7 +15,7 @@ Module.register("helloworld",{
},
getTemplate: function () {
return "helloworld.html"
return "helloworld.njk"
},
getTemplateData: function () {