Comparing version 1.0.0-beta.4 to 1.0.0
@@ -142,2 +142,3 @@ (function (global, factory) { | ||
var lastIndex = 0; | ||
var parseOptions = env.parse; | ||
templateLitReg.lastIndex = 0; | ||
@@ -160,3 +161,8 @@ singleQuoteReg.lastIndex = 0; | ||
} | ||
var prefixes = (env.parse.exec + env.parse.interpolate + env.parse.raw).split('').join('|'); | ||
var prefixes = (parseOptions.exec + | ||
parseOptions.interpolate + | ||
parseOptions.special + | ||
parseOptions.raw) | ||
.split('') | ||
.join('|'); | ||
var parseOpenReg = new RegExp('([^]*?)' + env.tags[0] + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g'); | ||
@@ -182,11 +188,14 @@ var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + env.tags[1] + ')', 'g'); | ||
var currentType = ''; | ||
if (prefix === env.parse.exec) { | ||
if (prefix === parseOptions.exec) { | ||
currentType = 'e'; | ||
} | ||
else if (prefix === env.parse.raw) { | ||
else if (prefix === parseOptions.raw) { | ||
currentType = 'r'; | ||
} | ||
else if (prefix === env.parse.interpolate) { | ||
else if (prefix === parseOptions.interpolate) { | ||
currentType = 'i'; | ||
} | ||
else if (prefix === parseOptions.special) { | ||
currentType = 's'; | ||
} | ||
currentObj = { t: currentType, val: content }; | ||
@@ -304,2 +313,6 @@ break; | ||
} | ||
else if (type === 's') { | ||
returnStr += 'tR+=E.' + content + ';'; | ||
// reference | ||
} | ||
} | ||
@@ -357,2 +370,3 @@ } | ||
raw: '~', | ||
special: '@', | ||
exec: '' | ||
@@ -359,0 +373,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Eta={})}(this,(function(e){"use strict";function t(e){var n,r,a=new Error(e);return n=a,r=t.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,a}function n(e,n,r){var a=n.slice(0,r).split(/\n/),i=a.length,o=a[i-1].length+1;throw t(e+=" at line "+i+" col "+o+":\n\n "+n.split(/\n/)[i-1]+"\n "+Array(o).join(" ")+"^")}t.prototype=Object.create(Error.prototype,{name:{value:"Eta Error",enumerable:!1}});var r=new Function("return this;")().Promise;function a(e,t,n){for(var r in t)a=t,i=r,Object.prototype.hasOwnProperty.call(a,i)&&(e[r]=t[r]);var a,i;return e}var i={"&":"&","<":"<",'"':""","'":"'"};function o(e){return i[e]}var s=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,c=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,l=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function u(e,t){var r=[],a=!1,i=0;function o(e,n){e&&(e=function(e,t,n,r){var a,i;return Array.isArray(t.autoTrim)?(a=t.autoTrim[1],i=t.autoTrim[0]):a=i=t.autoTrim,(n||!1===n)&&(a=n),(r||!1===r)&&(i=r),i||a?"slurp"===a&&"slurp"===i?e.trim():("_"===a||"slurp"===a?e=String.prototype.trimLeft?e.trimLeft():e.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==a&&"nl"!==a||(e=e.replace(/^(?:\r\n|\n|\r)/,"")),"_"===i||"slurp"===i?e=String.prototype.trimRight?e.trimRight():e.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==i&&"nl"!==i||(e=e.replace(/(?:\r\n|\n|\r)$/,"")),e):e}(e,t,a,n))&&(e=e.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),r.push(e))}s.lastIndex=0,c.lastIndex=0,l.lastIndex=0;for(var u,p=(t.parse.exec+t.parse.interpolate+t.parse.raw).split("").join("|"),f=new RegExp("([^]*?)"+t.tags[0]+"(-|_)?\\s*("+p+")?\\s*","g"),d=new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+t.tags[1]+")","g");u=f.exec(e);){i=u[0].length+u.index;var g,h=u[1],x=u[2],v=u[3]||"";o(h,x),d.lastIndex=i;for(var m=!1;g=d.exec(e);){if(g[1]){var y=e.slice(i,g.index);f.lastIndex=i=d.lastIndex,a=g[2];var w="";v===t.parse.exec?w="e":v===t.parse.raw?w="r":v===t.parse.interpolate&&(w="i"),m={t:w,val:y};break}var I=g[0];if("/*"===I){var E=e.indexOf("*/",d.lastIndex);-1===E&&n("unclosed comment",e,g.index),d.lastIndex=E}else if("'"===I){c.lastIndex=g.index,c.exec(e)?d.lastIndex=c.lastIndex:n("unclosed string",e,g.index)}else if('"'===I){l.lastIndex=g.index,l.exec(e)?d.lastIndex=l.lastIndex:n("unclosed string",e,g.index)}else if("`"===I){s.lastIndex=g.index,s.exec(e)?d.lastIndex=s.lastIndex:n("unclosed string",e,g.index)}}m?r.push(m):n("unclosed tag",e,u.index+h.length)}if(o(e.slice(i,e.length),!1),t.plugins)for(var b=0;b<t.plugins.length;b++){var F=t.plugins[b];F.processAST&&(r=F.processAST(r,t))}return r}function p(e,t){var n=u(e,t),r="var tR='';"+(t.useWith?"with("+t.varName+"||{}){":"")+function(e,t){var n=0,r=e.length,a="";for(;n<r;n++){var i=e[n];if("string"==typeof i){a+="tR+='"+i+"';"}else{var o=i.t,s=i.val||"";"r"===o?a+="tR+="+s+";":"i"===o?(t.autoEscape&&(s="E.e("+s+")"),a+="tR+="+s+";"):"e"===o&&(a+=s+"\n")}}return a}(n,t)+"if(cb){cb(null,tR)} return tR"+(t.useWith?"}":"");if(t.plugins)for(var a=0;a<t.plugins.length;a++){var i=t.plugins[a];i.processFnString&&(r=i.processFnString(r,t))}return r}var f=new(function(){function e(e){this.cache=e}return e.prototype.define=function(e,t){this.cache[e]=t},e.prototype.get=function(e){return this.cache[e]},e.prototype.remove=function(e){delete this.cache[e]},e.prototype.reset=function(){this.cache={}},e.prototype.load=function(e){a(this.cache,e)},e}())({});function d(e,n){var r=this.templates.get(e);if(!r)throw t('Could not fetch template "'+e+'"');return r(n,this)}var g={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,tags:["<%","%>"],parse:{interpolate:"=",raw:"~",exec:""},async:!1,templates:f,cache:!1,plugins:[],useWith:!1,e:function(e){var t=String(e);return/[&<"']/.test(t)?t.replace(/[&<"']/g,o):t},include:d};function h(e,t){var n={};return a(n,g),t&&a(n,t),e&&a(n,e),n}function x(e,n){var r,a=h(n||{});if(a.async)try{r=new Function("return (async function(){}).constructor;")()}catch(e){throw e instanceof SyntaxError?t("This environment doesn't support async/await"):e}else r=Function;try{return new r(a.varName,"E","cb",p(e,a))}catch(n){throw n instanceof SyntaxError?t("Bad template syntax\n\n"+n.message+"\n"+Array(n.message.length+1).join("=")+"\n"+p(e,a)):n}}function v(e,t){var n;return t.cache&&t.name&&t.templates.get(t.name)?t.templates.get(t.name):(n="function"==typeof e?e:x(e,t),t.cache&&t.name&&t.templates.define(t.name,n),n)}d.bind(g),e.compile=x,e.compileToString=p,e.defaultConfig=g,e.getConfig=h,e.parse=u,e.render=function(e,n,a,i){var o=h(a||{});if(!o.async)return v(e,o)(n,o);if(!i){if("function"==typeof r)return new r((function(t,r){try{t(v(e,o)(n,o))}catch(e){r(e)}}));throw t("Please provide a callback function, this env doesn't support Promises")}try{v(e,o)(n,o,i)}catch(e){return i(e)}},e.templates=f,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Eta={})}(this,(function(e){"use strict";function t(e){var n,r,a=new Error(e);return n=a,r=t.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,a}function n(e,n,r){var a=n.slice(0,r).split(/\n/),i=a.length,o=a[i-1].length+1;throw t(e+=" at line "+i+" col "+o+":\n\n "+n.split(/\n/)[i-1]+"\n "+Array(o).join(" ")+"^")}t.prototype=Object.create(Error.prototype,{name:{value:"Eta Error",enumerable:!1}});var r=new Function("return this;")().Promise;function a(e,t,n){for(var r in t)a=t,i=r,Object.prototype.hasOwnProperty.call(a,i)&&(e[r]=t[r]);var a,i;return e}var i={"&":"&","<":"<",'"':""","'":"'"};function o(e){return i[e]}var s=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,c=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,l=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function u(e,t){var r=[],a=!1,i=0,o=t.parse;function u(e,n){e&&(e=function(e,t,n,r){var a,i;return Array.isArray(t.autoTrim)?(a=t.autoTrim[1],i=t.autoTrim[0]):a=i=t.autoTrim,(n||!1===n)&&(a=n),(r||!1===r)&&(i=r),i||a?"slurp"===a&&"slurp"===i?e.trim():("_"===a||"slurp"===a?e=String.prototype.trimLeft?e.trimLeft():e.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==a&&"nl"!==a||(e=e.replace(/^(?:\r\n|\n|\r)/,"")),"_"===i||"slurp"===i?e=String.prototype.trimRight?e.trimRight():e.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==i&&"nl"!==i||(e=e.replace(/(?:\r\n|\n|\r)$/,"")),e):e}(e,t,a,n))&&(e=e.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),r.push(e))}s.lastIndex=0,c.lastIndex=0,l.lastIndex=0;for(var p,f=(o.exec+o.interpolate+o.special+o.raw).split("").join("|"),d=new RegExp("([^]*?)"+t.tags[0]+"(-|_)?\\s*("+f+")?\\s*","g"),g=new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+t.tags[1]+")","g");p=d.exec(e);){i=p[0].length+p.index;var h,x=p[1],v=p[2],m=p[3]||"";u(x,v),g.lastIndex=i;for(var y=!1;h=g.exec(e);){if(h[1]){var w=e.slice(i,h.index);d.lastIndex=i=g.lastIndex,a=h[2];var I="";m===o.exec?I="e":m===o.raw?I="r":m===o.interpolate?I="i":m===o.special&&(I="s"),y={t:I,val:w};break}var E=h[0];if("/*"===E){var b=e.indexOf("*/",g.lastIndex);-1===b&&n("unclosed comment",e,h.index),g.lastIndex=b}else if("'"===E){c.lastIndex=h.index,c.exec(e)?g.lastIndex=c.lastIndex:n("unclosed string",e,h.index)}else if('"'===E){l.lastIndex=h.index,l.exec(e)?g.lastIndex=l.lastIndex:n("unclosed string",e,h.index)}else if("`"===E){s.lastIndex=h.index,s.exec(e)?g.lastIndex=s.lastIndex:n("unclosed string",e,h.index)}}y?r.push(y):n("unclosed tag",e,p.index+x.length)}if(u(e.slice(i,e.length),!1),t.plugins)for(var F=0;F<t.plugins.length;F++){var R=t.plugins[F];R.processAST&&(r=R.processAST(r,t))}return r}function p(e,t){var n=u(e,t),r="var tR='';"+(t.useWith?"with("+t.varName+"||{}){":"")+function(e,t){var n=0,r=e.length,a="";for(;n<r;n++){var i=e[n];if("string"==typeof i){a+="tR+='"+i+"';"}else{var o=i.t,s=i.val||"";"r"===o?a+="tR+="+s+";":"i"===o?(t.autoEscape&&(s="E.e("+s+")"),a+="tR+="+s+";"):"e"===o?a+=s+"\n":"s"===o&&(a+="tR+=E."+s+";")}}return a}(n,t)+"if(cb){cb(null,tR)} return tR"+(t.useWith?"}":"");if(t.plugins)for(var a=0;a<t.plugins.length;a++){var i=t.plugins[a];i.processFnString&&(r=i.processFnString(r,t))}return r}var f=new(function(){function e(e){this.cache=e}return e.prototype.define=function(e,t){this.cache[e]=t},e.prototype.get=function(e){return this.cache[e]},e.prototype.remove=function(e){delete this.cache[e]},e.prototype.reset=function(){this.cache={}},e.prototype.load=function(e){a(this.cache,e)},e}())({});function d(e,n){var r=this.templates.get(e);if(!r)throw t('Could not fetch template "'+e+'"');return r(n,this)}var g={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,tags:["<%","%>"],parse:{interpolate:"=",raw:"~",special:"@",exec:""},async:!1,templates:f,cache:!1,plugins:[],useWith:!1,e:function(e){var t=String(e);return/[&<"']/.test(t)?t.replace(/[&<"']/g,o):t},include:d};function h(e,t){var n={};return a(n,g),t&&a(n,t),e&&a(n,e),n}function x(e,n){var r,a=h(n||{});if(a.async)try{r=new Function("return (async function(){}).constructor;")()}catch(e){throw e instanceof SyntaxError?t("This environment doesn't support async/await"):e}else r=Function;try{return new r(a.varName,"E","cb",p(e,a))}catch(n){throw n instanceof SyntaxError?t("Bad template syntax\n\n"+n.message+"\n"+Array(n.message.length+1).join("=")+"\n"+p(e,a)):n}}function v(e,t){var n;return t.cache&&t.name&&t.templates.get(t.name)?t.templates.get(t.name):(n="function"==typeof e?e:x(e,t),t.cache&&t.name&&t.templates.define(t.name,n),n)}d.bind(g),e.compile=x,e.compileToString=p,e.defaultConfig=g,e.getConfig=h,e.parse=u,e.render=function(e,n,a,i){var o=h(a||{});if(!o.async)return v(e,o)(n,o);if(!i){if("function"==typeof r)return new r((function(t,r){try{t(v(e,o)(n,o))}catch(e){r(e)}}));throw t("Please provide a callback function, this env doesn't support Promises")}try{v(e,o)(n,o,i)}catch(e){return i(e)}},e.templates=f,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=eta.min.js.map |
@@ -140,2 +140,3 @@ 'use strict'; | ||
var lastIndex = 0; | ||
var parseOptions = env.parse; | ||
templateLitReg.lastIndex = 0; | ||
@@ -158,3 +159,8 @@ singleQuoteReg.lastIndex = 0; | ||
} | ||
var prefixes = (env.parse.exec + env.parse.interpolate + env.parse.raw).split('').join('|'); | ||
var prefixes = (parseOptions.exec + | ||
parseOptions.interpolate + | ||
parseOptions.special + | ||
parseOptions.raw) | ||
.split('') | ||
.join('|'); | ||
var parseOpenReg = new RegExp('([^]*?)' + env.tags[0] + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g'); | ||
@@ -180,11 +186,14 @@ var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + env.tags[1] + ')', 'g'); | ||
var currentType = ''; | ||
if (prefix === env.parse.exec) { | ||
if (prefix === parseOptions.exec) { | ||
currentType = 'e'; | ||
} | ||
else if (prefix === env.parse.raw) { | ||
else if (prefix === parseOptions.raw) { | ||
currentType = 'r'; | ||
} | ||
else if (prefix === env.parse.interpolate) { | ||
else if (prefix === parseOptions.interpolate) { | ||
currentType = 'i'; | ||
} | ||
else if (prefix === parseOptions.special) { | ||
currentType = 's'; | ||
} | ||
currentObj = { t: currentType, val: content }; | ||
@@ -302,2 +311,6 @@ break; | ||
} | ||
else if (type === 's') { | ||
returnStr += 'tR+=E.' + content + ';'; | ||
// reference | ||
} | ||
} | ||
@@ -355,2 +368,3 @@ } | ||
raw: '~', | ||
special: '@', | ||
exec: '' | ||
@@ -357,0 +371,0 @@ }, |
@@ -136,2 +136,3 @@ function setPrototypeOf(obj, proto) { | ||
var lastIndex = 0; | ||
var parseOptions = env.parse; | ||
templateLitReg.lastIndex = 0; | ||
@@ -154,3 +155,8 @@ singleQuoteReg.lastIndex = 0; | ||
} | ||
var prefixes = (env.parse.exec + env.parse.interpolate + env.parse.raw).split('').join('|'); | ||
var prefixes = (parseOptions.exec + | ||
parseOptions.interpolate + | ||
parseOptions.special + | ||
parseOptions.raw) | ||
.split('') | ||
.join('|'); | ||
var parseOpenReg = new RegExp('([^]*?)' + env.tags[0] + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g'); | ||
@@ -176,11 +182,14 @@ var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + env.tags[1] + ')', 'g'); | ||
var currentType = ''; | ||
if (prefix === env.parse.exec) { | ||
if (prefix === parseOptions.exec) { | ||
currentType = 'e'; | ||
} | ||
else if (prefix === env.parse.raw) { | ||
else if (prefix === parseOptions.raw) { | ||
currentType = 'r'; | ||
} | ||
else if (prefix === env.parse.interpolate) { | ||
else if (prefix === parseOptions.interpolate) { | ||
currentType = 'i'; | ||
} | ||
else if (prefix === parseOptions.special) { | ||
currentType = 's'; | ||
} | ||
currentObj = { t: currentType, val: content }; | ||
@@ -298,2 +307,6 @@ break; | ||
} | ||
else if (type === 's') { | ||
returnStr += 'tR+=E.' + content + ';'; | ||
// reference | ||
} | ||
} | ||
@@ -351,2 +364,3 @@ } | ||
raw: '~', | ||
special: '@', | ||
exec: '' | ||
@@ -353,0 +367,0 @@ }, |
@@ -13,2 +13,3 @@ import { TemplateFunction } from './compile'; | ||
exec: string; | ||
special: string; | ||
}; | ||
@@ -15,0 +16,0 @@ e: (str: string) => string; |
import { EtaConfig } from './config'; | ||
export declare type TagType = 'r' | 'e' | 'i' | ''; | ||
export declare type TagType = 'r' | 'e' | 'i' | 's' | ''; | ||
export interface TemplateObject { | ||
@@ -4,0 +4,0 @@ t: TagType; |
{ | ||
"name": "eta", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0", | ||
"description": "Lightweight, fast, and powerful embedded JS template engine", | ||
@@ -77,6 +77,6 @@ "keywords": [ | ||
"global": { | ||
"branches": 70, | ||
"branches": 85, | ||
"functions": 95, | ||
"lines": 90, | ||
"statements": 90 | ||
"lines": 95, | ||
"statements": 95 | ||
} | ||
@@ -83,0 +83,0 @@ }, |
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
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
226382
2018
0