Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eta

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eta - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

30

dist/browser/eta.dev.js

@@ -85,3 +85,4 @@ (function (global, factory) {

// full slurp
if (String.prototype.trimLeft) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!String.prototype.trimLeft) {
str = str.trimLeft();

@@ -101,3 +102,4 @@ }

// full slurp
if (String.prototype.trimRight) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!String.prototype.trimRight) {
str = str.trimRight();

@@ -141,2 +143,6 @@ }

var doubleQuoteReg = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;
function escapeRegExp(string) {
// From MDN
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
function parse(str, env) {

@@ -174,7 +180,17 @@ var buffer = [];

}
var prefixes = (parseOptions.exec + parseOptions.interpolate + parseOptions.raw)
.split('')
.join('|');
var parseOpenReg = new RegExp('([^]*?)' + env.tags[0] + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g');
var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + env.tags[1] + ')', 'g');
var prefixes = [parseOptions.exec, parseOptions.interpolate, parseOptions.raw].reduce(function (accumulator, prefix) {
if (accumulator && prefix) {
return accumulator + '|' + escapeRegExp(prefix);
}
else if (prefix) {
// accumulator is falsy
return escapeRegExp(prefix);
}
else {
// prefix and accumulator are both falsy
return accumulator;
}
}, '');
var parseOpenReg = new RegExp('([^]*?)' + escapeRegExp(env.tags[0]) + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g');
var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + escapeRegExp(env.tags[1]) + ')', 'g');
// TODO: benchmark having the \s* on either side vs using str.trim()

@@ -181,0 +197,0 @@ var m;

@@ -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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};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))}t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),s.lastIndex=0,c.lastIndex=0,l.lastIndex=0;for(var p,f=(o.exec+o.interpolate+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],m=p[2],v=p[3]||"";u(x,m),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="";v===o.exec?I="e":v===o.raw?I="r":v===o.interpolate&&(I="i"),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 S=t.plugins[F];S.processAST&&(r=S.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"],rmWhitespace:!1,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 m(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 m(e,o)(n,o);if(!i){if("function"==typeof r)return new r((function(t,r){try{t(m(e,o)(n,o))}catch(e){r(e)}}));throw t("Please provide a callback function, this env doesn't support Promises")}try{m(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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function o(e){return i[e]}var s=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,c=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,u=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function l(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function p(e,t){var r=[],a=!1,i=0,o=t.parse;function p(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))}t.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),s.lastIndex=0,c.lastIndex=0,u.lastIndex=0;for(var f,d=[o.exec,o.interpolate,o.raw].reduce((function(e,t){return e&&t?e+"|"+l(t):t?l(t):e}),""),g=new RegExp("([^]*?)"+l(t.tags[0])+"(-|_)?\\s*("+d+")?\\s*","g"),h=new RegExp("'|\"|`|\\/\\*|(\\s*(-|_)?"+l(t.tags[1])+")","g");f=g.exec(e);){i=f[0].length+f.index;var x,m=f[1],v=f[2],y=f[3]||"";p(m,v),h.lastIndex=i;for(var w=!1;x=h.exec(e);){if(x[1]){var I=e.slice(i,x.index);g.lastIndex=i=h.lastIndex,a=x[2];var E="";y===o.exec?E="e":y===o.raw?E="r":y===o.interpolate&&(E="i"),w={t:E,val:I};break}var b=x[0];if("/*"===b){var F=e.indexOf("*/",h.lastIndex);-1===F&&n("unclosed comment",e,x.index),h.lastIndex=F}else if("'"===b){c.lastIndex=x.index,c.exec(e)?h.lastIndex=c.lastIndex:n("unclosed string",e,x.index)}else if('"'===b){u.lastIndex=x.index,u.exec(e)?h.lastIndex=u.lastIndex:n("unclosed string",e,x.index)}else if("`"===b){s.lastIndex=x.index,s.exec(e)?h.lastIndex=s.lastIndex:n("unclosed string",e,x.index)}}w?r.push(w):n("unclosed tag",e,f.index+m.length)}if(p(e.slice(i,e.length),!1),t.plugins)for(var S=0;S<t.plugins.length;S++){var R=t.plugins[S];R.processAST&&(r=R.processAST(r,t))}return r}function f(e,t){var n=p(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 d=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 g(e,n){var r=this.templates.get(e);if(!r)throw t('Could not fetch template "'+e+'"');return r(n,this)}var h={varName:"it",autoTrim:[!1,"nl"],rmWhitespace:!1,autoEscape:!0,tags:["<%","%>"],parse:{interpolate:"=",raw:"~",exec:""},async:!1,templates:d,cache:!1,plugins:[],useWith:!1,e:function(e){var t=String(e);return/[&<>"']/.test(t)?t.replace(/[&<>"']/g,o):t},include:g};function x(e,t){var n={};return a(n,h),t&&a(n,t),e&&a(n,e),n}function m(e,n){var r,a=x(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",f(e,a))}catch(n){throw n instanceof SyntaxError?t("Bad template syntax\n\n"+n.message+"\n"+Array(n.message.length+1).join("=")+"\n"+f(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:m(e,t),t.cache&&t.name&&t.templates.define(t.name,n),n)}g.bind(h),e.compile=m,e.compileToString=f,e.defaultConfig=h,e.getConfig=x,e.parse=p,e.render=function(e,n,a,i){var o=x(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=d,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=eta.min.js.map

@@ -83,3 +83,4 @@ 'use strict';

// full slurp
if (String.prototype.trimLeft) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!String.prototype.trimLeft) {
str = str.trimLeft();

@@ -99,3 +100,4 @@ }

// full slurp
if (String.prototype.trimRight) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!String.prototype.trimRight) {
str = str.trimRight();

@@ -139,2 +141,6 @@ }

var doubleQuoteReg = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;
function escapeRegExp(string) {
// From MDN
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
function parse(str, env) {

@@ -172,7 +178,17 @@ var buffer = [];

}
var prefixes = (parseOptions.exec + parseOptions.interpolate + parseOptions.raw)
.split('')
.join('|');
var parseOpenReg = new RegExp('([^]*?)' + env.tags[0] + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g');
var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + env.tags[1] + ')', 'g');
var prefixes = [parseOptions.exec, parseOptions.interpolate, parseOptions.raw].reduce(function (accumulator, prefix) {
if (accumulator && prefix) {
return accumulator + '|' + escapeRegExp(prefix);
}
else if (prefix) {
// accumulator is falsy
return escapeRegExp(prefix);
}
else {
// prefix and accumulator are both falsy
return accumulator;
}
}, '');
var parseOpenReg = new RegExp('([^]*?)' + escapeRegExp(env.tags[0]) + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g');
var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + escapeRegExp(env.tags[1]) + ')', 'g');
// TODO: benchmark having the \s* on either side vs using str.trim()

@@ -179,0 +195,0 @@ var m;

@@ -79,3 +79,4 @@ function setPrototypeOf(obj, proto) {

// full slurp
if (String.prototype.trimLeft) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!String.prototype.trimLeft) {
str = str.trimLeft();

@@ -95,3 +96,4 @@ }

// full slurp
if (String.prototype.trimRight) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!String.prototype.trimRight) {
str = str.trimRight();

@@ -135,2 +137,6 @@ }

var doubleQuoteReg = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;
function escapeRegExp(string) {
// From MDN
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
function parse(str, env) {

@@ -168,7 +174,17 @@ var buffer = [];

}
var prefixes = (parseOptions.exec + parseOptions.interpolate + parseOptions.raw)
.split('')
.join('|');
var parseOpenReg = new RegExp('([^]*?)' + env.tags[0] + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g');
var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + env.tags[1] + ')', 'g');
var prefixes = [parseOptions.exec, parseOptions.interpolate, parseOptions.raw].reduce(function (accumulator, prefix) {
if (accumulator && prefix) {
return accumulator + '|' + escapeRegExp(prefix);
}
else if (prefix) {
// accumulator is falsy
return escapeRegExp(prefix);
}
else {
// prefix and accumulator are both falsy
return accumulator;
}
}, '');
var parseOpenReg = new RegExp('([^]*?)' + escapeRegExp(env.tags[0]) + '(-|_)?\\s*(' + prefixes + ')?\\s*', 'g');
var parseCloseReg = new RegExp('\'|"|`|\\/\\*|(\\s*(-|_)?' + escapeRegExp(env.tags[1]) + ')', 'g');
// TODO: benchmark having the \s* on either side vs using str.trim()

@@ -175,0 +191,0 @@ var m;

{
"name": "eta",
"version": "1.1.1",
"version": "1.2.0",
"description": "Lightweight, fast, and powerful embedded JS template engine",

@@ -5,0 +5,0 @@ "keywords": [

@@ -34,3 +34,3 @@ # eta (η)

- Eta is more lightweight. Eta weighs less than **2.5KB gzipped**, while EJS is **4.4KB gzipped**
- Eta compiles and renders templates **_much_ faster than EJS**. Check out these benchmarks: https://cdn.statically.io/gh/eta-dev/eta/master/browser-tests/benchmark.html
- Eta compiles and renders templates **_much_ faster than EJS**. Check out these benchmarks: https://ghcdn.rawgit.org/eta-dev/eta/master/browser-tests/benchmark.html
- Eta allows left whitespace control (with `-`), something that doesn't work in EJS because EJS uses `-` on the left side to indicate that the value shouldn't be escaped. Instead, Eta uses `~` to output a raw value

@@ -51,3 +51,3 @@ - Eta gives you more flexibility with delimeters -- you could set them to `{{` and `}}`, for example, while with EJS this isn't possible

Eta and doT.js both allow embedded JavaScript, and [both have best-in-class performance](https://cdn.statically.io/gh/eta-dev/eta/master/browser-tests/benchmark.html) when compared to other template engines (though Eta is slightly faster with HTML-escaped templates). Here are some of the differences between Eta and doT.js:
Eta and doT.js both allow embedded JavaScript, and [both have best-in-class performance](https://ghcdn.rawgit.org/eta-dev/eta/master/browser-tests/benchmark.html) when compared to other template engines (though Eta is slightly faster with HTML-escaped templates). Here are some of the differences between Eta and doT.js:

@@ -72,3 +72,3 @@ - Eta allows you to control how you strip preceding and trailing whitespace after tags.

- Eta is more lightweight. Eta weighs less than **2.5KB gzipped**, while Handlebars is **~22KB gzipped**
- Eta compiles and renders templates **_much_ faster than Handlebars** -- around **7x faster**. Check out these benchmarks: https://cdn.statically.io/gh/eta-dev/eta/master/browser-tests/benchmark.html
- Eta compiles and renders templates **_much_ faster than Handlebars** -- around **7x faster**. Check out these benchmarks: https://ghcdn.rawgit.org/eta-dev/eta/master/browser-tests/benchmark.html
- Eta allows you to set custom delimiters

@@ -128,3 +128,3 @@ - Eta supports plugins

- 🚀 Super Fast
- Check out [these benchmarks](https://cdn.statically.io/gh/eta-dev/eta/master/browser-tests/benchmark.html)
- Check out [these benchmarks](https://ghcdn.rawgit.org/eta-dev/eta/master/browser-tests/benchmark.html)
- ⚡️ Async support

@@ -131,0 +131,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

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