Socket
Socket
Sign inDemoInstall

template7

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

template7 - npm Package Compare versions

Comparing version 1.2.3 to 1.2.5

2

bower.json

@@ -8,3 +8,3 @@ {

"description": "Mobile-first JavaScript template engine",
"version": "1.2.3",
"version": "1.2.5",
"author": "Vladimir Kharlampidi",

@@ -11,0 +11,0 @@ "homepage": "http://www.idangero.us/template7/",

# Change Log
## Template7 v1.2.5 - Released on August 2, 2017
* `js_compare` helper has been renamed to `js_if` helper. `js_compare` is still available for backwards compatibility
* Added support for `@index`, `@first`, `@last`, `@key`, `@root`, `@global` variables to `js` and `js_if` helpers
* Added support for parent access (e.g. `../title`) to `js` and `js_if` helpers
* Added support for parent data access within loops, e.g. `../../@index`
## Template7 v1.2.3 - Released on May 12, 2017
* Fixed ES2015 module build to have ES 2015 syntax
* Fixed ES2015 module build to have ES 2015 syntax
## Template7 v1.2.1 - Released on April 19, 2017
* Added ES2015 module build
* Added ES2015 module build
## Template7 v1.2.0 - Released on April 15, 2017
* Added support for node.js and commonjs
* Added support for node.js and commonjs
## Template7 v1.1.4 - Released on December 12, 2016
* Fixed issue with quotes being added to helpers hash content
* Fixed issue with quotes being added to helpers hash content
## Template7 v1.1.2 - Released on September 1, 2016
* Added number, boolean, and single-quote-strings argument types support for template helpers #19
* Ability to use single/double quotes in helpers and mix them
* Added number, boolean, and single-quote-strings argument types support for template helpers #19
* Ability to use single/double quotes in helpers and mix them
## Template7 v1.1.0 - Released on October 3, 2015
* Access to data (@index, @key) and root context (@root) in partials
* Access to data (@index, @key) and root context (@root) in partials
## Template7 v1.0.7 - Released on September 28, 2015
* Added check is variable is `null` and don't output it in this case
* Added check is variable is `null` and don't output it in this case
## Template7 v1.0.6 - Released on June 20, 2015
* Partials support:
* `registerPartial(name, template)` method to register partial
* `unregisterPartial(name, template)` method to unregister partial
* `>` helper to include partials like `{{> list}}`
* New `escape` helper for escaping strings
* Partials support:
* `registerPartial(name, template)` method to register partial
* `unregisterPartial(name, template)` method to unregister partial
* `>` helper to include partials like `{{> list}}`
* New `escape` helper for escaping strings

@@ -32,0 +38,0 @@ ## Template7 v1.0.5 - Released on March 28, 2015

/**
* template7 1.2.3
* Template7 1.2.5
* Mobile-first HTML template engine

@@ -13,3 +13,3 @@ *

*
* Released on: May 12, 2017
* Released on: August 2, 2017
*/

@@ -211,2 +211,32 @@ (function (global, factory) {

}
function parseJsVariable(expression, replace, object) {
return expression.split(/([+ -*/^])/g).map(function (part) {
if (part.indexOf(replace) < 0) { return part; }
if (!object) { return JSON.stringify(''); }
var variable = object;
if (part.indexOf((replace + ".")) >= 0) {
part.split((replace + "."))[1].split('.').forEach(function (partName) {
if (variable[partName]) { variable = variable[partName]; }
else { variable = 'undefined'; }
});
}
return JSON.stringify(variable);
}).join('');
}
function parseJsParents(expression, parents) {
return expression.split(/([+ -*^])/g).map(function (part) {
if (part.indexOf('../') < 0) { return part; }
if (!parents || parents.length === 0) { return JSON.stringify(''); }
var levelsUp = part.split('../').length - 1;
var parentData = levelsUp > parents.length ? parents[parents.length - 1] : parents[levelsUp - 1];
var variable = parentData;
var parentPart = part.replace(/..\//g, '');
parentPart.split('.').forEach(function (partName) {
if (variable[partName]) { variable = variable[partName]; }
else { variable = 'undefined'; }
});
return JSON.stringify(variable);
}).join('');
}
var Template7 = function Template7(template) {

@@ -216,9 +246,12 @@ var t = this;

function getCompileVar(name, ctx) {
function getCompileVar(name, ctx, data) {
if ( data === void 0 ) data = 'data_1';
var variable = ctx;
var parts;
var levelsUp = 0;
var newDepth;
if (name.indexOf('../') === 0) {
var newDepth = variable.split('_')[1] - levelsUp;
levelsUp = name.split('../').length - 1;
newDepth = variable.split('_')[1] - levelsUp;
variable = "ctx_" + (newDepth >= 1 ? newDepth : 1);

@@ -238,6 +271,10 @@ parts = name.split('../')[levelsUp].split('.');

if (part.indexOf('@') === 0) {
var dataLevel = data.split('_')[1];
if (levelsUp > 0) {
dataLevel = newDepth;
}
if (i > 0) {
variable += "[(data && data." + (part.replace('@', '')) + ")]";
variable += "[(data_" + dataLevel + " && data_" + dataLevel + "." + (part.replace('@', '')) + ")]";
} else {
variable = "(data && data." + (name.replace('@', '')) + ")";
variable = "(data_" + dataLevel + " && data_" + dataLevel + "." + (part.replace('@', '')) + ")";
}

@@ -252,6 +289,5 @@ } else if (isFinite(part)) {

}
return variable;
}
function getCompiledArguments(contextArray, ctx) {
function getCompiledArguments(contextArray, ctx, data) {
var arr = [];

@@ -262,3 +298,3 @@ for (var i = 0; i < contextArray.length; i += 1) {

else {
arr.push(getCompileVar(contextArray[i], ctx));
arr.push(getCompileVar(contextArray[i], ctx, data));
}

@@ -278,2 +314,3 @@ }

var ctx = "ctx_" + depth;
var data = "data_" + depth;
if (blocks.length === 0) {

@@ -294,5 +331,5 @@ return function empty() { return ''; };

if (depth === 1) {
resultString += "(function (" + ctx + ", data, root) {\n";
resultString += "(function (" + ctx + ", " + data + ", root) {\n";
} else {
resultString += "(function (" + ctx + ", data) {\n";
resultString += "(function (" + ctx + ", " + data + ") {\n";
}

@@ -318,3 +355,3 @@ if (depth === 1) {

if (block.type === 'variable') {
variable = getCompileVar(block.contextName, ctx);
variable = getCompileVar(block.contextName, ctx, data);
resultString += "r += c(" + variable + ", " + ctx + ");";

@@ -324,15 +361,25 @@ }

if (block.type === 'helper') {
var parents = (void 0);
if (ctx !== 'ctx_1') {
var level = ctx.split('_')[1];
var parentsString = "ctx_" + (level - 1);
for (var j = level - 2; j >= 1; j -= 1) {
parentsString += ", ctx_" + j;
}
parents = "[" + parentsString + "]";
} else {
parents = "[" + ctx + "]";
}
if (block.helperName in t.helpers) {
compiledArguments = getCompiledArguments(block.contextName, ctx);
resultString += "r += (Template7.helpers." + (block.helperName) + ").call(" + ctx + ", " + (compiledArguments && ((compiledArguments + ", "))) + "{hash:" + (JSON.stringify(block.hash)) + ", data: data || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root});";
compiledArguments = getCompiledArguments(block.contextName, ctx, data);
resultString += "r += (Template7.helpers." + (block.helperName) + ").call(" + ctx + ", " + (compiledArguments && ((compiledArguments + ", "))) + "{hash:" + (JSON.stringify(block.hash)) + ", data: " + data + " || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root, parents: " + parents + "});";
} else if (block.contextName.length > 0) {
throw new Error(("Template7: Missing helper: \"" + (block.helperName) + "\""));
} else {
variable = getCompileVar(block.helperName, ctx);
variable = getCompileVar(block.helperName, ctx, data);
resultString += "if (" + variable + ") {";
resultString += "if (isArray(" + variable + ")) {";
resultString += "r += (Template7.helpers.each).call(" + ctx + ", " + variable + ", {hash:" + (JSON.stringify(block.hash)) + ", data: data || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root});";
resultString += "r += (Template7.helpers.each).call(" + ctx + ", " + variable + ", {hash:" + (JSON.stringify(block.hash)) + ", data: " + data + " || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root, parents: " + parents + "});";
resultString += '}else {';
resultString += "r += (Template7.helpers.with).call(" + ctx + ", " + variable + ", {hash:" + (JSON.stringify(block.hash)) + ", data: data || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root});";
resultString += "r += (Template7.helpers.with).call(" + ctx + ", " + variable + ", {hash:" + (JSON.stringify(block.hash)) + ", data: " + data + " || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root, parents: " + parents + "});";
resultString += '}}';

@@ -428,16 +475,56 @@ }

js: function js(expression, options) {
var data = options.data;
var func;
if (expression.indexOf('return') >= 0) {
func = "(function(){" + expression + "})";
var execute = expression;
('index first last key').split(' ').forEach(function (prop) {
if (typeof data[prop] !== 'undefined') {
var re1 = new RegExp(("this.@" + prop), 'g');
var re2 = new RegExp(("@" + prop), 'g');
execute = execute
.replace(re1, JSON.stringify(data[prop]))
.replace(re2, JSON.stringify(data[prop]));
}
});
if (options.root && execute.indexOf('@root') >= 0) {
execute = parseJsVariable(execute, '@root', options.root);
}
if (execute.indexOf('@global') >= 0) {
execute = parseJsVariable(execute, '@global', template7Context.Template7.global);
}
if (execute.indexOf('../') >= 0) {
execute = parseJsParents(execute, options.parents);
}
if (execute.indexOf('return') >= 0) {
func = "(function(){" + execute + "})";
} else {
func = "(function(){return (" + expression + ")})";
func = "(function(){return (" + execute + ")})";
}
return eval.call(this, func).call(this);
},
js_compare: function js_compare(expression, options) {
js_if: function js_if(expression, options) {
var data = options.data;
var func;
if (expression.indexOf('return') >= 0) {
func = "(function(){" + expression + "})";
var execute = expression;
('index first last key').split(' ').forEach(function (prop) {
if (typeof data[prop] !== 'undefined') {
var re1 = new RegExp(("this.@" + prop), 'g');
var re2 = new RegExp(("@" + prop), 'g');
execute = execute
.replace(re1, JSON.stringify(data[prop]))
.replace(re2, JSON.stringify(data[prop]));
}
});
if (options.root && execute.indexOf('@root') >= 0) {
execute = parseJsVariable(execute, '@root', options.root);
}
if (execute.indexOf('@global') >= 0) {
execute = parseJsVariable(execute, '@global', Template7.global);
}
if (execute.indexOf('../') >= 0) {
execute = parseJsParents(execute, options.parents);
}
if (execute.indexOf('return') >= 0) {
func = "(function(){" + execute + "})";
} else {
func = "(function(){return (" + expression + ")})";
func = "(function(){return (" + execute + ")})";
}

@@ -453,2 +540,3 @@ var condition = eval.call(this, func).call(this);

};
Template7.prototype.helpers.js_compare = Template7.prototype.helpers.js_if;
function t7(template, data) {

@@ -455,0 +543,0 @@ if (arguments.length === 2) {

/**
* template7 1.2.3
* Template7 1.2.5
* Mobile-first HTML template engine

@@ -13,5 +13,5 @@ *

*
* Released on: May 12, 2017
* Released on: August 2, 2017
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Template7=t()}(this,function(){"use strict";function e(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.apply(e)}function t(e){return"function"==typeof e}function r(e){return(void 0!==o&&o.escape?o.escape(e):e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function n(e){var t,r,n,i=e.replace(/[{}#}]/g,"").split(" "),a=[];for(r=0;r<i.length;r+=1){var o=i[r],s=void 0,f=void 0;if(0===r)a.push(o);else if(0===o.indexOf('"')||0===o.indexOf("'"))if(s=0===o.indexOf('"')?p:l,f=0===o.indexOf('"')?'"':"'",2===o.match(s).length)a.push(o);else{for(t=0,n=r+1;n<i.length;n+=1)if(o+=" "+i[n],i[n].indexOf(f)>=0){t=n,a.push(o);break}t&&(r=t)}else if(o.indexOf("=")>0){var c=o.split("="),u=c[0],h=c[1];if(s||(s=0===h.indexOf('"')?p:l,f=0===h.indexOf('"')?'"':"'"),2!==h.match(s).length){for(t=0,n=r+1;n<i.length;n+=1)if(h+=" "+i[n],i[n].indexOf(f)>=0){t=n;break}t&&(r=t)}var d=[u,h.replace(s,"")];a.push(d)}else a.push(o)}return a}function i(t){var r,i,a=[];if(!t)return[];var o=t.split(/({{[^{^}]*}})/);for(r=0;r<o.length;r+=1){var l=o[r];if(""!==l)if(l.indexOf("{{")<0)a.push({type:"plain",content:l});else{if(l.indexOf("{/")>=0)continue;if(l.indexOf("{#")<0&&l.indexOf(" ")<0&&l.indexOf("else")<0){a.push({type:"variable",contextName:l.replace(/[{}]/g,"")});continue}var p=n(l),s=p[0],f=">"===s,c=[],u={};for(i=1;i<p.length;i+=1){var h=p[i];e(h)?u[h[0]]="false"!==h[1]&&h[1]:c.push(h)}if(l.indexOf("{#")>=0){var d="",v="",g=0,m=void 0,x=!1,y=!1,O=0;for(i=r+1;i<o.length;i+=1)if(o[i].indexOf("{{#")>=0&&(O+=1),o[i].indexOf("{{/")>=0&&(O-=1),o[i].indexOf("{{#"+s)>=0)d+=o[i],y&&(v+=o[i]),g+=1;else if(o[i].indexOf("{{/"+s)>=0){if(!(g>0)){m=i,x=!0;break}g-=1,d+=o[i],y&&(v+=o[i])}else o[i].indexOf("else")>=0&&0===O?y=!0:(y||(d+=o[i]),y&&(v+=o[i]));x&&(m&&(r=m),a.push({type:"helper",helperName:s,contextName:c,content:d,inverseContent:v,hash:u}))}else l.indexOf(" ")>0&&(f&&(s="_partial",c[0]&&(c[0]='"'+c[0].replace(/"|'/g,"")+'"')),a.push({type:"helper",helperName:s,contextName:c,hash:u}))}}return a}function a(e,t){if(2===arguments.length){var r=new s(e),n=r.compile()(t);return r=null,n}return new s(e)}var o;o="undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;var l=new RegExp("'","g"),p=new RegExp('"',"g"),s=function(e){function t(e,t){var r,n=t,i=0;if(0===e.indexOf("../")){var a=n.split("_")[1]-i;i=e.split("../").length-1,n="ctx_"+(a>=1?a:1),r=e.split("../")[i].split(".")}else 0===e.indexOf("@global")?(n="Template7.global",r=e.split("@global.")[1].split(".")):0===e.indexOf("@root")?(n="root",r=e.split("@root.")[1].split(".")):r=e.split(".");for(var o=0;o<r.length;o+=1){var l=r[o];0===l.indexOf("@")?o>0?n+="[(data && data."+l.replace("@","")+")]":n="(data && data."+e.replace("@","")+")":isFinite(l)?n+="["+l+"]":"this"===l||l.indexOf("this.")>=0||l.indexOf("this[")>=0||l.indexOf("this(")>=0?n=l.replace("this",t):n+="."+l}return n}function r(e,r){for(var n=[],i=0;i<e.length;i+=1)/^['"]/.test(e[i])?n.push(e[i]):/^(true|false|\d+)$/.test(e[i])?n.push(e[i]):n.push(t(e[i],r));return n.join(", ")}function n(e,l){function p(e,t){return e.content?n(e.content,t):function(){return""}}function s(e,t){return e.inverseContent?n(e.inverseContent,t):function(){return""}}if(void 0===e&&(e=a.template),void 0===l&&(l=1),"string"!=typeof e)throw new Error("Template7: Template must be a string");var f=i(e),c="ctx_"+l;if(0===f.length)return function(){return""};var u="";u+=1===l?"(function ("+c+", data, root) {\n":"(function ("+c+", data) {\n",1===l&&(u+="function isArray(arr){return Object.prototype.toString.apply(arr) === '[object Array]';}\n",u+="function isFunction(func){return (typeof func === 'function');}\n",u+='function c(val, ctx) {if (typeof val !== "undefined" && val !== null) {if (isFunction(val)) {return val.call(ctx);} else return val;} else return "";}\n',u+="root = root || ctx_1 || {};\n"),u+="var r = '';\n";var h;for(h=0;h<f.length;h+=1){var d=f[h];if("plain"!==d.type){var v=void 0,g=void 0;if("variable"===d.type&&(v=t(d.contextName,c),u+="r += c("+v+", "+c+");"),"helper"===d.type)if(d.helperName in a.helpers)g=r(d.contextName,c),u+="r += (Template7.helpers."+d.helperName+").call("+c+", "+(g&&g+", ")+"{hash:"+JSON.stringify(d.hash)+", data: data || {}, fn: "+p(d,l+1)+", inverse: "+s(d,l+1)+", root: root});";else{if(d.contextName.length>0)throw new Error('Template7: Missing helper: "'+d.helperName+'"');v=t(d.helperName,c),u+="if ("+v+") {",u+="if (isArray("+v+")) {",u+="r += (Template7.helpers.each).call("+c+", "+v+", {hash:"+JSON.stringify(d.hash)+", data: data || {}, fn: "+p(d,l+1)+", inverse: "+s(d,l+1)+", root: root});",u+="}else {",u+="r += (Template7.helpers.with).call("+c+", "+v+", {hash:"+JSON.stringify(d.hash)+", data: data || {}, fn: "+p(d,l+1)+", inverse: "+s(d,l+1)+", root: root});",u+="}}"}}else u+="r +='"+d.content.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/'/g,"\\'")+"';"}return u+="\nreturn r;})",eval.call(o,u)}var a=this;a.template=e,a.compile=function(e){return a.compiled||(a.compiled=n(e)),a.compiled}};return s.prototype={options:{},partials:{},helpers:{_partial:function(e,t){var r=s.prototype.partials[e];if(!r||r&&!r.template)return"";r.compiled||(r.compiled=new s(r.template).compile());var n=this;for(var i in t.hash)n[i]=t.hash[i];return r.compiled(n,t.data,t.root)},escape:function(e,t){if("string"!=typeof e)throw new Error('Template7: Passed context to "escape" helper should be a string');return r(e)},if:function(e,r){var n=e;return t(n)&&(n=n.call(this)),n?r.fn(this,r.data):r.inverse(this,r.data)},unless:function(e,r){var n=e;return t(n)&&(n=n.call(this)),n?r.inverse(this,r.data):r.fn(this,r.data)},each:function(r,n){var i=r,a="",o=0;if(t(i)&&(i=i.call(this)),e(i)){for(n.hash.reverse&&(i=i.reverse()),o=0;o<i.length;o+=1)a+=n.fn(i[o],{first:0===o,last:o===i.length-1,index:o});n.hash.reverse&&(i=i.reverse())}else for(var l in i)o+=1,a+=n.fn(i[l],{key:l});return o>0?a:n.inverse(this)},with:function(e,r){var n=e;return t(n)&&(n=e.call(this)),r.fn(n)},join:function(e,r){var n=e;return t(n)&&(n=n.call(this)),n.join(r.hash.delimiter||r.hash.delimeter)},js:function(e,t){var r;return r=e.indexOf("return")>=0?"(function(){"+e+"})":"(function(){return ("+e+")})",eval.call(this,r).call(this)},js_compare:function(e,t){var r;return r=e.indexOf("return")>=0?"(function(){"+e+"})":"(function(){return ("+e+")})",eval.call(this,r).call(this)?t.fn(this,t.data):t.inverse(this,t.data)}}},a.registerHelper=function(e,t){s.prototype.helpers[e]=t},a.unregisterHelper=function(e){s.prototype.helpers[e]=void 0,delete s.prototype.helpers[e]},a.registerPartial=function(e,t){s.prototype.partials[e]={template:t}},a.unregisterPartial=function(e){s.prototype.partials[e]&&(s.prototype.partials[e]=void 0,delete s.prototype.partials[e])},a.compile=function(e,t){return new s(e,t).compile()},a.options=s.prototype.options,a.helpers=s.prototype.helpers,a.partials=s.prototype.partials,a});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Template7=t()}(this,function(){"use strict";function e(e){return Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.apply(e)}function t(e){return"function"==typeof e}function r(e){return(void 0!==f&&f.escape?f.escape(e):e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function n(e){var t,r,n,i=e.replace(/[{}#}]/g,"").split(" "),a=[];for(r=0;r<i.length;r+=1){var o=i[r],l=void 0,f=void 0;if(0===r)a.push(o);else if(0===o.indexOf('"')||0===o.indexOf("'"))if(l=0===o.indexOf('"')?s:p,f=0===o.indexOf('"')?'"':"'",2===o.match(l).length)a.push(o);else{for(t=0,n=r+1;n<i.length;n+=1)if(o+=" "+i[n],i[n].indexOf(f)>=0){t=n,a.push(o);break}t&&(r=t)}else if(o.indexOf("=")>0){var c=o.split("="),u=c[0],h=c[1];if(l||(l=0===h.indexOf('"')?s:p,f=0===h.indexOf('"')?'"':"'"),2!==h.match(l).length){for(t=0,n=r+1;n<i.length;n+=1)if(h+=" "+i[n],i[n].indexOf(f)>=0){t=n;break}t&&(r=t)}var d=[u,h.replace(l,"")];a.push(d)}else a.push(o)}return a}function i(t){var r,i,a=[];if(!t)return[];var o=t.split(/({{[^{^}]*}})/);for(r=0;r<o.length;r+=1){var l=o[r];if(""!==l)if(l.indexOf("{{")<0)a.push({type:"plain",content:l});else{if(l.indexOf("{/")>=0)continue;if(l.indexOf("{#")<0&&l.indexOf(" ")<0&&l.indexOf("else")<0){a.push({type:"variable",contextName:l.replace(/[{}]/g,"")});continue}var f=n(l),p=f[0],s=">"===p,c=[],u={};for(i=1;i<f.length;i+=1){var h=f[i];e(h)?u[h[0]]="false"!==h[1]&&h[1]:c.push(h)}if(l.indexOf("{#")>=0){var d="",v="",g=0,x=void 0,y=!1,O=!1,m=0;for(i=r+1;i<o.length;i+=1)if(o[i].indexOf("{{#")>=0&&(m+=1),o[i].indexOf("{{/")>=0&&(m-=1),o[i].indexOf("{{#"+p)>=0)d+=o[i],O&&(v+=o[i]),g+=1;else if(o[i].indexOf("{{/"+p)>=0){if(!(g>0)){x=i,y=!0;break}g-=1,d+=o[i],O&&(v+=o[i])}else o[i].indexOf("else")>=0&&0===m?O=!0:(O||(d+=o[i]),O&&(v+=o[i]));y&&(x&&(r=x),a.push({type:"helper",helperName:p,contextName:c,content:d,inverseContent:v,hash:u}))}else l.indexOf(" ")>0&&(s&&(p="_partial",c[0]&&(c[0]='"'+c[0].replace(/"|'/g,"")+'"')),a.push({type:"helper",helperName:p,contextName:c,hash:u}))}}return a}function a(e,t,r){return e.split(/([+ -*\/^])/g).map(function(e){if(e.indexOf(t)<0)return e;if(!r)return JSON.stringify("");var n=r;return e.indexOf(t+".")>=0&&e.split(t+".")[1].split(".").forEach(function(e){n=n[e]?n[e]:"undefined"}),JSON.stringify(n)}).join("")}function o(e,t){return e.split(/([+ -*^])/g).map(function(e){if(e.indexOf("../")<0)return e;if(!t||0===t.length)return JSON.stringify("");var r=e.split("../").length-1,n=r>t.length?t[t.length-1]:t[r-1],i=n;return e.replace(/..\//g,"").split(".").forEach(function(e){i=i[e]?i[e]:"undefined"}),JSON.stringify(i)}).join("")}function l(e,t){if(2===arguments.length){var r=new c(e),n=r.compile()(t);return r=null,n}return new c(e)}var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;var p=new RegExp("'","g"),s=new RegExp('"',"g"),c=function(e){function t(e,t,r){void 0===r&&(r="data_1");var n,i,a=t,o=0;0===e.indexOf("../")?(o=e.split("../").length-1,i=a.split("_")[1]-o,a="ctx_"+(i>=1?i:1),n=e.split("../")[o].split(".")):0===e.indexOf("@global")?(a="Template7.global",n=e.split("@global.")[1].split(".")):0===e.indexOf("@root")?(a="root",n=e.split("@root.")[1].split(".")):n=e.split(".");for(var l=0;l<n.length;l+=1){var f=n[l];if(0===f.indexOf("@")){var p=r.split("_")[1];o>0&&(p=i),l>0?a+="[(data_"+p+" && data_"+p+"."+f.replace("@","")+")]":a="(data_"+p+" && data_"+p+"."+f.replace("@","")+")"}else isFinite(f)?a+="["+f+"]":"this"===f||f.indexOf("this.")>=0||f.indexOf("this[")>=0||f.indexOf("this(")>=0?a=f.replace("this",t):a+="."+f}return a}function r(e,r,n){for(var i=[],a=0;a<e.length;a+=1)/^['"]/.test(e[a])?i.push(e[a]):/^(true|false|\d+)$/.test(e[a])?i.push(e[a]):i.push(t(e[a],r,n));return i.join(", ")}function n(e,o){function l(e,t){return e.content?n(e.content,t):function(){return""}}function p(e,t){return e.inverseContent?n(e.inverseContent,t):function(){return""}}if(void 0===e&&(e=a.template),void 0===o&&(o=1),"string"!=typeof e)throw new Error("Template7: Template must be a string");var s=i(e),c="ctx_"+o,u="data_"+o;if(0===s.length)return function(){return""};var h="";h+=1===o?"(function ("+c+", "+u+", root) {\n":"(function ("+c+", "+u+") {\n",1===o&&(h+="function isArray(arr){return Object.prototype.toString.apply(arr) === '[object Array]';}\n",h+="function isFunction(func){return (typeof func === 'function');}\n",h+='function c(val, ctx) {if (typeof val !== "undefined" && val !== null) {if (isFunction(val)) {return val.call(ctx);} else return val;} else return "";}\n',h+="root = root || ctx_1 || {};\n"),h+="var r = '';\n";var d;for(d=0;d<s.length;d+=1){var v=s[d];if("plain"!==v.type){var g=void 0,x=void 0;if("variable"===v.type&&(g=t(v.contextName,c,u),h+="r += c("+g+", "+c+");"),"helper"===v.type){var y=void 0;if("ctx_1"!==c){for(var O=c.split("_")[1],m="ctx_"+(O-1),b=O-2;b>=1;b-=1)m+=", ctx_"+b;y="["+m+"]"}else y="["+c+"]";if(v.helperName in a.helpers)x=r(v.contextName,c,u),h+="r += (Template7.helpers."+v.helperName+").call("+c+", "+(x&&x+", ")+"{hash:"+JSON.stringify(v.hash)+", data: "+u+" || {}, fn: "+l(v,o+1)+", inverse: "+p(v,o+1)+", root: root, parents: "+y+"});";else{if(v.contextName.length>0)throw new Error('Template7: Missing helper: "'+v.helperName+'"');g=t(v.helperName,c,u),h+="if ("+g+") {",h+="if (isArray("+g+")) {",h+="r += (Template7.helpers.each).call("+c+", "+g+", {hash:"+JSON.stringify(v.hash)+", data: "+u+" || {}, fn: "+l(v,o+1)+", inverse: "+p(v,o+1)+", root: root, parents: "+y+"});",h+="}else {",h+="r += (Template7.helpers.with).call("+c+", "+g+", {hash:"+JSON.stringify(v.hash)+", data: "+u+" || {}, fn: "+l(v,o+1)+", inverse: "+p(v,o+1)+", root: root, parents: "+y+"});",h+="}}"}}}else h+="r +='"+v.content.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/'/g,"\\'")+"';"}return h+="\nreturn r;})",eval.call(f,h)}var a=this;a.template=e,a.compile=function(e){return a.compiled||(a.compiled=n(e)),a.compiled}};return c.prototype={options:{},partials:{},helpers:{_partial:function(e,t){var r=c.prototype.partials[e];if(!r||r&&!r.template)return"";r.compiled||(r.compiled=new c(r.template).compile());var n=this;for(var i in t.hash)n[i]=t.hash[i];return r.compiled(n,t.data,t.root)},escape:function(e,t){if("string"!=typeof e)throw new Error('Template7: Passed context to "escape" helper should be a string');return r(e)},if:function(e,r){var n=e;return t(n)&&(n=n.call(this)),n?r.fn(this,r.data):r.inverse(this,r.data)},unless:function(e,r){var n=e;return t(n)&&(n=n.call(this)),n?r.inverse(this,r.data):r.fn(this,r.data)},each:function(r,n){var i=r,a="",o=0;if(t(i)&&(i=i.call(this)),e(i)){for(n.hash.reverse&&(i=i.reverse()),o=0;o<i.length;o+=1)a+=n.fn(i[o],{first:0===o,last:o===i.length-1,index:o});n.hash.reverse&&(i=i.reverse())}else for(var l in i)o+=1,a+=n.fn(i[l],{key:l});return o>0?a:n.inverse(this)},with:function(e,r){var n=e;return t(n)&&(n=e.call(this)),r.fn(n)},join:function(e,r){var n=e;return t(n)&&(n=n.call(this)),n.join(r.hash.delimiter||r.hash.delimeter)},js:function(e,t){var r,n=t.data,i=e;return"index first last key".split(" ").forEach(function(e){if(void 0!==n[e]){var t=new RegExp("this.@"+e,"g"),r=new RegExp("@"+e,"g");i=i.replace(t,JSON.stringify(n[e])).replace(r,JSON.stringify(n[e]))}}),t.root&&i.indexOf("@root")>=0&&(i=a(i,"@root",t.root)),i.indexOf("@global")>=0&&(i=a(i,"@global",f.Template7.global)),i.indexOf("../")>=0&&(i=o(i,t.parents)),r=i.indexOf("return")>=0?"(function(){"+i+"})":"(function(){return ("+i+")})",eval.call(this,r).call(this)},js_if:function(e,t){var r,n=t.data,i=e;return"index first last key".split(" ").forEach(function(e){if(void 0!==n[e]){var t=new RegExp("this.@"+e,"g"),r=new RegExp("@"+e,"g");i=i.replace(t,JSON.stringify(n[e])).replace(r,JSON.stringify(n[e]))}}),t.root&&i.indexOf("@root")>=0&&(i=a(i,"@root",t.root)),i.indexOf("@global")>=0&&(i=a(i,"@global",c.global)),i.indexOf("../")>=0&&(i=o(i,t.parents)),r=i.indexOf("return")>=0?"(function(){"+i+"})":"(function(){return ("+i+")})",eval.call(this,r).call(this)?t.fn(this,t.data):t.inverse(this,t.data)}}},c.prototype.helpers.js_compare=c.prototype.helpers.js_if,l.registerHelper=function(e,t){c.prototype.helpers[e]=t},l.unregisterHelper=function(e){c.prototype.helpers[e]=void 0,delete c.prototype.helpers[e]},l.registerPartial=function(e,t){c.prototype.partials[e]={template:t}},l.unregisterPartial=function(e){c.prototype.partials[e]&&(c.prototype.partials[e]=void 0,delete c.prototype.partials[e])},l.compile=function(e,t){return new c(e,t).compile()},l.options=c.prototype.options,l.helpers=c.prototype.helpers,l.partials=c.prototype.partials,l});
//# sourceMappingURL=template7.min.js.map
/**
* template7 1.2.3
* Template7 1.2.5
* Mobile-first HTML template engine

@@ -13,3 +13,3 @@ *

*
* Released on: May 12, 2017
* Released on: August 2, 2017
*/

@@ -205,2 +205,32 @@ let template7Context;

}
function parseJsVariable(expression, replace, object) {
return expression.split(/([+ -*/^])/g).map((part) => {
if (part.indexOf(replace) < 0) return part;
if (!object) return JSON.stringify('');
let variable = object;
if (part.indexOf(`${replace}.`) >= 0) {
part.split(`${replace}.`)[1].split('.').forEach((partName) => {
if (variable[partName]) variable = variable[partName];
else variable = 'undefined';
});
}
return JSON.stringify(variable);
}).join('');
}
function parseJsParents(expression, parents) {
return expression.split(/([+ -*^])/g).map((part) => {
if (part.indexOf('../') < 0) return part;
if (!parents || parents.length === 0) return JSON.stringify('');
const levelsUp = part.split('../').length - 1;
const parentData = levelsUp > parents.length ? parents[parents.length - 1] : parents[levelsUp - 1];
let variable = parentData;
const parentPart = part.replace(/..\//g, '');
parentPart.split('.').forEach((partName) => {
if (variable[partName]) variable = variable[partName];
else variable = 'undefined';
});
return JSON.stringify(variable);
}).join('');
}
class Template7 {

@@ -211,9 +241,10 @@ constructor(template) {

function getCompileVar(name, ctx) {
function getCompileVar(name, ctx, data = 'data_1') {
let variable = ctx;
let parts;
let levelsUp = 0;
let newDepth;
if (name.indexOf('../') === 0) {
const newDepth = variable.split('_')[1] - levelsUp;
levelsUp = name.split('../').length - 1;
newDepth = variable.split('_')[1] - levelsUp;
variable = `ctx_${newDepth >= 1 ? newDepth : 1}`;

@@ -233,6 +264,10 @@ parts = name.split('../')[levelsUp].split('.');

if (part.indexOf('@') === 0) {
let dataLevel = data.split('_')[1];
if (levelsUp > 0) {
dataLevel = newDepth;
}
if (i > 0) {
variable += `[(data && data.${part.replace('@', '')})]`;
variable += `[(data_${dataLevel} && data_${dataLevel}.${part.replace('@', '')})]`;
} else {
variable = `(data && data.${name.replace('@', '')})`;
variable = `(data_${dataLevel} && data_${dataLevel}.${part.replace('@', '')})`;
}

@@ -247,6 +282,5 @@ } else if (isFinite(part)) {

}
return variable;
}
function getCompiledArguments(contextArray, ctx) {
function getCompiledArguments(contextArray, ctx, data) {
const arr = [];

@@ -257,3 +291,3 @@ for (let i = 0; i < contextArray.length; i += 1) {

else {
arr.push(getCompileVar(contextArray[i], ctx));
arr.push(getCompileVar(contextArray[i], ctx, data));
}

@@ -270,2 +304,3 @@ }

const ctx = `ctx_${depth}`;
const data = `data_${depth}`;
if (blocks.length === 0) {

@@ -286,5 +321,5 @@ return function empty() { return ''; };

if (depth === 1) {
resultString += `(function (${ctx}, data, root) {\n`;
resultString += `(function (${ctx}, ${data}, root) {\n`;
} else {
resultString += `(function (${ctx}, data) {\n`;
resultString += `(function (${ctx}, ${data}) {\n`;
}

@@ -310,3 +345,3 @@ if (depth === 1) {

if (block.type === 'variable') {
variable = getCompileVar(block.contextName, ctx);
variable = getCompileVar(block.contextName, ctx, data);
resultString += `r += c(${variable}, ${ctx});`;

@@ -316,15 +351,25 @@ }

if (block.type === 'helper') {
let parents;
if (ctx !== 'ctx_1') {
const level = ctx.split('_')[1];
let parentsString = `ctx_${level - 1}`;
for (let j = level - 2; j >= 1; j -= 1) {
parentsString += `, ctx_${j}`;
}
parents = `[${parentsString}]`;
} else {
parents = `[${ctx}]`;
}
if (block.helperName in t.helpers) {
compiledArguments = getCompiledArguments(block.contextName, ctx);
resultString += `r += (Template7.helpers.${block.helperName}).call(${ctx}, ${compiledArguments && (`${compiledArguments}, `)}{hash:${JSON.stringify(block.hash)}, data: data || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root});`;
compiledArguments = getCompiledArguments(block.contextName, ctx, data);
resultString += `r += (Template7.helpers.${block.helperName}).call(${ctx}, ${compiledArguments && (`${compiledArguments}, `)}{hash:${JSON.stringify(block.hash)}, data: ${data} || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root, parents: ${parents}});`;
} else if (block.contextName.length > 0) {
throw new Error(`Template7: Missing helper: "${block.helperName}"`);
} else {
variable = getCompileVar(block.helperName, ctx);
variable = getCompileVar(block.helperName, ctx, data);
resultString += `if (${variable}) {`;
resultString += `if (isArray(${variable})) {`;
resultString += `r += (Template7.helpers.each).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: data || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root});`;
resultString += `r += (Template7.helpers.each).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: ${data} || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root, parents: ${parents}});`;
resultString += '}else {';
resultString += `r += (Template7.helpers.with).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: data || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root});`;
resultString += `r += (Template7.helpers.with).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: ${data} || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root, parents: ${parents}});`;
resultString += '}}';

@@ -421,16 +466,56 @@ }

js(expression, options) {
const data = options.data;
let func;
if (expression.indexOf('return') >= 0) {
func = `(function(){${expression}})`;
let execute = expression;
('index first last key').split(' ').forEach((prop) => {
if (typeof data[prop] !== 'undefined') {
const re1 = new RegExp(`this.@${prop}`, 'g');
const re2 = new RegExp(`@${prop}`, 'g');
execute = execute
.replace(re1, JSON.stringify(data[prop]))
.replace(re2, JSON.stringify(data[prop]));
}
});
if (options.root && execute.indexOf('@root') >= 0) {
execute = parseJsVariable(execute, '@root', options.root);
}
if (execute.indexOf('@global') >= 0) {
execute = parseJsVariable(execute, '@global', template7Context.Template7.global);
}
if (execute.indexOf('../') >= 0) {
execute = parseJsParents(execute, options.parents);
}
if (execute.indexOf('return') >= 0) {
func = `(function(){${execute}})`;
} else {
func = `(function(){return (${expression})})`;
func = `(function(){return (${execute})})`;
}
return eval.call(this, func).call(this);
},
js_compare(expression, options) {
js_if(expression, options) {
const data = options.data;
let func;
if (expression.indexOf('return') >= 0) {
func = `(function(){${expression}})`;
let execute = expression;
('index first last key').split(' ').forEach((prop) => {
if (typeof data[prop] !== 'undefined') {
const re1 = new RegExp(`this.@${prop}`, 'g');
const re2 = new RegExp(`@${prop}`, 'g');
execute = execute
.replace(re1, JSON.stringify(data[prop]))
.replace(re2, JSON.stringify(data[prop]));
}
});
if (options.root && execute.indexOf('@root') >= 0) {
execute = parseJsVariable(execute, '@root', options.root);
}
if (execute.indexOf('@global') >= 0) {
execute = parseJsVariable(execute, '@global', Template7.global);
}
if (execute.indexOf('../') >= 0) {
execute = parseJsParents(execute, options.parents);
}
if (execute.indexOf('return') >= 0) {
func = `(function(){${execute}})`;
} else {
func = `(function(){return (${expression})})`;
func = `(function(){return (${execute})})`;
}

@@ -446,2 +531,3 @@ const condition = eval.call(this, func).call(this);

};
Template7.prototype.helpers.js_compare = Template7.prototype.helpers.js_if;
function t7(template, data) {

@@ -448,0 +534,0 @@ if (arguments.length === 2) {

@@ -27,3 +27,3 @@ (function(){

'/**',
' * <%= pkg.name %> <%= pkg.version %>',
' * Template7 <%= pkg.version %>',
' * <%= pkg.description %>',

@@ -30,0 +30,0 @@ ' * ',

{
"name": "template7",
"version": "1.2.3",
"version": "1.2.5",
"description": "Mobile-first HTML template engine",

@@ -5,0 +5,0 @@ "main": "dist/template7.js",

@@ -190,2 +190,32 @@ let template7Context;

}
function parseJsVariable(expression, replace, object) {
return expression.split(/([+ -*/^])/g).map((part) => {
if (part.indexOf(replace) < 0) return part;
if (!object) return JSON.stringify('');
let variable = object;
if (part.indexOf(`${replace}.`) >= 0) {
part.split(`${replace}.`)[1].split('.').forEach((partName) => {
if (variable[partName]) variable = variable[partName];
else variable = 'undefined';
});
}
return JSON.stringify(variable);
}).join('');
}
function parseJsParents(expression, parents) {
return expression.split(/([+ -*^])/g).map((part) => {
if (part.indexOf('../') < 0) return part;
if (!parents || parents.length === 0) return JSON.stringify('');
const levelsUp = part.split('../').length - 1;
const parentData = levelsUp > parents.length ? parents[parents.length - 1] : parents[levelsUp - 1];
let variable = parentData;
const parentPart = part.replace(/..\//g, '');
parentPart.split('.').forEach((partName) => {
if (variable[partName]) variable = variable[partName];
else variable = 'undefined';
});
return JSON.stringify(variable);
}).join('');
}
class Template7 {

@@ -196,9 +226,10 @@ constructor(template) {

function getCompileVar(name, ctx) {
function getCompileVar(name, ctx, data = 'data_1') {
let variable = ctx;
let parts;
let levelsUp = 0;
let newDepth;
if (name.indexOf('../') === 0) {
const newDepth = variable.split('_')[1] - levelsUp;
levelsUp = name.split('../').length - 1;
newDepth = variable.split('_')[1] - levelsUp;
variable = `ctx_${newDepth >= 1 ? newDepth : 1}`;

@@ -218,6 +249,10 @@ parts = name.split('../')[levelsUp].split('.');

if (part.indexOf('@') === 0) {
let dataLevel = data.split('_')[1];
if (levelsUp > 0) {
dataLevel = newDepth;
}
if (i > 0) {
variable += `[(data && data.${part.replace('@', '')})]`;
variable += `[(data_${dataLevel} && data_${dataLevel}.${part.replace('@', '')})]`;
} else {
variable = `(data && data.${name.replace('@', '')})`;
variable = `(data_${dataLevel} && data_${dataLevel}.${part.replace('@', '')})`;
}

@@ -232,6 +267,5 @@ } else if (isFinite(part)) {

}
return variable;
}
function getCompiledArguments(contextArray, ctx) {
function getCompiledArguments(contextArray, ctx, data) {
const arr = [];

@@ -242,3 +276,3 @@ for (let i = 0; i < contextArray.length; i += 1) {

else {
arr.push(getCompileVar(contextArray[i], ctx));
arr.push(getCompileVar(contextArray[i], ctx, data));
}

@@ -255,2 +289,3 @@ }

const ctx = `ctx_${depth}`;
const data = `data_${depth}`;
if (blocks.length === 0) {

@@ -271,5 +306,5 @@ return function empty() { return ''; };

if (depth === 1) {
resultString += `(function (${ctx}, data, root) {\n`;
resultString += `(function (${ctx}, ${data}, root) {\n`;
} else {
resultString += `(function (${ctx}, data) {\n`;
resultString += `(function (${ctx}, ${data}) {\n`;
}

@@ -295,3 +330,3 @@ if (depth === 1) {

if (block.type === 'variable') {
variable = getCompileVar(block.contextName, ctx);
variable = getCompileVar(block.contextName, ctx, data);
resultString += `r += c(${variable}, ${ctx});`;

@@ -301,15 +336,25 @@ }

if (block.type === 'helper') {
let parents;
if (ctx !== 'ctx_1') {
const level = ctx.split('_')[1];
let parentsString = `ctx_${level - 1}`;
for (let j = level - 2; j >= 1; j -= 1) {
parentsString += `, ctx_${j}`;
}
parents = `[${parentsString}]`;
} else {
parents = `[${ctx}]`;
}
if (block.helperName in t.helpers) {
compiledArguments = getCompiledArguments(block.contextName, ctx);
resultString += `r += (Template7.helpers.${block.helperName}).call(${ctx}, ${compiledArguments && (`${compiledArguments}, `)}{hash:${JSON.stringify(block.hash)}, data: data || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root});`;
compiledArguments = getCompiledArguments(block.contextName, ctx, data);
resultString += `r += (Template7.helpers.${block.helperName}).call(${ctx}, ${compiledArguments && (`${compiledArguments}, `)}{hash:${JSON.stringify(block.hash)}, data: ${data} || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root, parents: ${parents}});`;
} else if (block.contextName.length > 0) {
throw new Error(`Template7: Missing helper: "${block.helperName}"`);
} else {
variable = getCompileVar(block.helperName, ctx);
variable = getCompileVar(block.helperName, ctx, data);
resultString += `if (${variable}) {`;
resultString += `if (isArray(${variable})) {`;
resultString += `r += (Template7.helpers.each).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: data || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root});`;
resultString += `r += (Template7.helpers.each).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: ${data} || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root, parents: ${parents}});`;
resultString += '}else {';
resultString += `r += (Template7.helpers.with).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: data || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root});`;
resultString += `r += (Template7.helpers.with).call(${ctx}, ${variable}, {hash:${JSON.stringify(block.hash)}, data: ${data} || {}, fn: ${getCompileFn(block, depth + 1)}, inverse: ${getCompileInverse(block, depth + 1)}, root: root, parents: ${parents}});`;
resultString += '}}';

@@ -406,16 +451,56 @@ }

js(expression, options) {
const data = options.data;
let func;
if (expression.indexOf('return') >= 0) {
func = `(function(){${expression}})`;
let execute = expression;
('index first last key').split(' ').forEach((prop) => {
if (typeof data[prop] !== 'undefined') {
const re1 = new RegExp(`this.@${prop}`, 'g');
const re2 = new RegExp(`@${prop}`, 'g');
execute = execute
.replace(re1, JSON.stringify(data[prop]))
.replace(re2, JSON.stringify(data[prop]));
}
});
if (options.root && execute.indexOf('@root') >= 0) {
execute = parseJsVariable(execute, '@root', options.root);
}
if (execute.indexOf('@global') >= 0) {
execute = parseJsVariable(execute, '@global', template7Context.Template7.global);
}
if (execute.indexOf('../') >= 0) {
execute = parseJsParents(execute, options.parents);
}
if (execute.indexOf('return') >= 0) {
func = `(function(){${execute}})`;
} else {
func = `(function(){return (${expression})})`;
func = `(function(){return (${execute})})`;
}
return eval.call(this, func).call(this);
},
js_compare(expression, options) {
js_if(expression, options) {
const data = options.data;
let func;
if (expression.indexOf('return') >= 0) {
func = `(function(){${expression}})`;
let execute = expression;
('index first last key').split(' ').forEach((prop) => {
if (typeof data[prop] !== 'undefined') {
const re1 = new RegExp(`this.@${prop}`, 'g');
const re2 = new RegExp(`@${prop}`, 'g');
execute = execute
.replace(re1, JSON.stringify(data[prop]))
.replace(re2, JSON.stringify(data[prop]));
}
});
if (options.root && execute.indexOf('@root') >= 0) {
execute = parseJsVariable(execute, '@root', options.root);
}
if (execute.indexOf('@global') >= 0) {
execute = parseJsVariable(execute, '@global', Template7.global);
}
if (execute.indexOf('../') >= 0) {
execute = parseJsParents(execute, options.parents);
}
if (execute.indexOf('return') >= 0) {
func = `(function(){${execute}})`;
} else {
func = `(function(){return (${expression})})`;
func = `(function(){return (${execute})})`;
}

@@ -431,2 +516,3 @@ const condition = eval.call(this, func).call(this);

};
Template7.prototype.helpers.js_compare = Template7.prototype.helpers.js_if;
function t7(template, data) {

@@ -433,0 +519,0 @@ if (arguments.length === 2) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc