Comparing version 1.2.20 to 1.3.0
@@ -48,3 +48,3 @@ "use strict"; | ||
this.compiled = "var include = function (request, customLocals) {\n" + " __ajs.inc(request, customLocals, __locals)\n" + " }" + " , render = __ajs.ren\n" + " , print = __ajs.out;\n" + "with(__locals) {\n" + "try {\n" + this._make(this.tree) + ";\n" + this._endFunc + "();\n" + "} catch(e) { " + this._errFunc + "(e, __filename) }\n" + "}"; | ||
this.compiled = "var include = function (request, customLocals) {\n" + " __ajs.inc(request, customLocals, __locals)\n" + " }" + " , mod = function (request, customLocals) {\n" + " __ajs.modInclude(request, customLocals, __locals)\n" + " }" + " , render = __ajs.ren\n" + " , print = __ajs.out;\n" + "with(__locals) {\n" + "try {\n" + this._make(this.tree) + ";\n" + this._endFunc + "();\n" + "} catch(e) { " + this._errFunc + "(e, __filename) }\n" + "}"; | ||
@@ -51,0 +51,0 @@ var fn = new Function('__ajs, __locals', this.compiled); |
@@ -106,2 +106,3 @@ "use strict"; | ||
_this._vmContext_.inc = _this._include.bind(_this); | ||
_this._vmContext_.modInclude = _this._moduleInclude.bind(_this); | ||
} | ||
@@ -204,2 +205,25 @@ | ||
/** | ||
* _moduleInclude | ||
* Include an ajs template from node_modules | ||
* | ||
* @name _moduleInclude | ||
* @function | ||
* @param {String} request The path to the included ajs file. | ||
* @param {Object} locals The template data. | ||
* @param {Object} pLocals The parent template data. | ||
*/ | ||
}, { | ||
key: '_moduleInclude', | ||
value: function _moduleInclude(request, locals, pLocals) { | ||
if (!request.endsWith(".ajs")) { | ||
request += ".ajs"; | ||
} | ||
var filename = path.resolve(VM.ROOT, request); | ||
return this._include(filename, locals, pLocals); | ||
} | ||
/** | ||
* _render | ||
@@ -462,2 +486,3 @@ * Renders the template. | ||
inc: this._include.bind(this), | ||
modInclude: this._moduleInclude.bind(this), | ||
ren: this._render.bind(this), | ||
@@ -498,2 +523,5 @@ flush: this._flush.bind(this), | ||
VM.ROOT = process.cwd(); | ||
Template.VM = VM; | ||
module.exports = Template; |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "1.2.20", | ||
"version": "1.3.0", | ||
"author": "Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)", | ||
@@ -17,0 +17,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2536
99028
1