mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
Allow use of .njk extension for template files.
This commit is contained in:
parent
c75662e720
commit
f4d5996a88
@ -86,7 +86,7 @@ var Module = Class.extend({
|
|||||||
var templateData = this.getTemplateData();
|
var templateData = this.getTemplateData();
|
||||||
|
|
||||||
// Check to see if we need to render a template string or a file.
|
// 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
|
// the template is a filename
|
||||||
this.nunjucksEnvironment().render(template, templateData, function (err, res) {
|
this.nunjucksEnvironment().render(template, templateData, function (err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -170,7 +170,10 @@ var Module = Class.extend({
|
|||||||
|
|
||||||
var self = this;
|
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) {
|
this._nunjucksEnvironment.addFilter("translate", function(str) {
|
||||||
return self.translate(str)
|
return self.translate(str)
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ Module.register("helloworld",{
|
|||||||
},
|
},
|
||||||
|
|
||||||
getTemplate: function () {
|
getTemplate: function () {
|
||||||
return "helloworld.html"
|
return "helloworld.njk"
|
||||||
},
|
},
|
||||||
|
|
||||||
getTemplateData: function () {
|
getTemplateData: function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user