@kosatyi/ejs 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ejs.cjs CHANGED
@@ -179,22 +179,22 @@ function element(tag, attrs, content) {
179
179
  var tags = [{
180
180
  symbol: '-',
181
181
  format: function format(value) {
182
- return "'+\n".concat(this.SAFE, "(").concat(value, ",1)+\n'");
182
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
183
183
  }
184
184
  }, {
185
185
  symbol: '=',
186
186
  format: function format(value) {
187
- return "'+\n".concat(this.SAFE, "(").concat(value, ")+\n'");
187
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
188
188
  }
189
189
  }, {
190
190
  symbol: '#',
191
191
  format: function format(value) {
192
- return "'+\n/**".concat(value, "**/+\n'");
192
+ return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
193
193
  }
194
194
  }, {
195
195
  symbol: '',
196
196
  format: function format(value) {
197
- return "')\n".concat(value, "\n").concat(this.BUFFER, "('");
197
+ return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
198
198
  }
199
199
  }];
200
200
  var match = function match(regex, text, callback) {
@@ -625,6 +625,7 @@ function init(options) {
625
625
  return path;
626
626
  };
627
627
  var view = {
628
+ safeValue: safeValue,
628
629
  element: element,
629
630
  output: function output(path, scope) {
630
631
  return view.template(path).then(function (template) {
package/dist/ejs.js CHANGED
@@ -175,22 +175,22 @@
175
175
  var tags = [{
176
176
  symbol: '-',
177
177
  format: function format(value) {
178
- return "'+\n".concat(this.SAFE, "(").concat(value, ",1)+\n'");
178
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
179
179
  }
180
180
  }, {
181
181
  symbol: '=',
182
182
  format: function format(value) {
183
- return "'+\n".concat(this.SAFE, "(").concat(value, ")+\n'");
183
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
184
184
  }
185
185
  }, {
186
186
  symbol: '#',
187
187
  format: function format(value) {
188
- return "'+\n/**".concat(value, "**/+\n'");
188
+ return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
189
189
  }
190
190
  }, {
191
191
  symbol: '',
192
192
  format: function format(value) {
193
- return "')\n".concat(value, "\n").concat(this.BUFFER, "('");
193
+ return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
194
194
  }
195
195
  }];
196
196
  var match = function match(regex, text, callback) {
@@ -621,6 +621,7 @@
621
621
  return path;
622
622
  };
623
623
  var view = {
624
+ safeValue: safeValue,
624
625
  element: element,
625
626
  output: function output(path, scope) {
626
627
  return view.template(path).then(function (template) {
package/dist/ejs.min.js CHANGED
@@ -1 +1 @@
1
- !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).ejs=t()}(this,(function(){"use strict";var n={},t={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",withObject:!0,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},e=function(){var n=[].slice.call(arguments),t=n.shift();return n.filter(t).pop()},r=function(n){return"function"==typeof n},o=function(n){return"string"==typeof n},i=function(n){return"boolean"==typeof n},c=new Function("try {return this===global;}catch(e){return false;}"),u={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},f=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},s=f(a),h=f(u),l=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+n).replace(s,(function(n){return a[n]}))},p=function(n,t,e){return null==(e=n)?"":t?l(e):e},v=function(n,t){var e=n,r=t.split("."),o=r.pop();return r.forEach((function(n){e=e[n]=e[n]||{}})),[e,o]},d=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];var r=t.shift();return t.filter((function(n){return n})).reduce((function(n,t){return Object.assign(n,t)}),r)},m=function(){},g=function(n,t){var e;for(e in n)y(n,e)&&t(n[e],e,n)},b=function(n,t){return function(n,t,e){var r=n instanceof Array,o=r?[]:{};return g(n,(function(n,e,i){var c=t(n,e,i);void 0!==c&&(r?o.push(c):o[e]=c)})),o}(n,(function(n,e){if(-1===t.indexOf(e))return n}))},w=function(n,t,e){return Promise.resolve(n).then(t.bind(e))},y=function(n,t){return n&&n.hasOwnProperty(t)},x=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],j=" ",E='"',O="/",k="<",F=">";function B(n,t,e){var r=[],o=-1===x.indexOf(n),i=function(n,t,e){var r=[];return g(n,(function(n,e,o){var i=t(n,e,o);void 0!==i&&r.push(i)})),r}(t,(function(n,t){if(null!=n)return[l(t),[E,l(n),E].join("")].join("=")})).join(j);return r.push([k,n,j,i,F].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([k,O,n,F].join("")),r.join("")}var $=[{symbol:"-",format:function(n){return"'+\n".concat(this.SAFE,"(").concat(n,",1)+\n'")}},{symbol:"=",format:function(n){return"'+\n".concat(this.SAFE,"(").concat(n,")+\n'")}},{symbol:"#",format:function(n){return"'+\n/**".concat(n,"**/+\n'")}},{symbol:"",format:function(n){return"')\n".concat(n,"\n").concat(this.BUFFER,"('")}}],S=function(n){var t=n.withObject,e=n.token,r=n.vars,o=[],i=[],c={match:"[ \\t]*",start:[e.start,"_"],end:["_",e.end]};$.forEach((function(n){o.push(e.start.concat(n.symbol).concat(e.regex).concat(e.end)),i.push(n.format.bind(r))}));var a=new RegExp(o.join("|").concat("|$"),"g"),f=new RegExp([c.match,c.start].join(""),"gm"),s=new RegExp([c.end,c.match].join(""),"gm");return function(n,e){var o=r.SCOPE,l=r.SAFE,p=r.BUFFER;n=(n=n.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(f,c.start).replace(s,c.end);var v="".concat(p,"('");!function(n,t,e){var r=0;t.replace(n,(function(){var n=[].slice.call(arguments,0,-1),t=n.pop(),o=n.shift();return e(n,r,t),r=t+o.length,o}))}(a,n,(function(t,e,r){v+=(""+n.slice(e,r)).replace(h,(function(n){return"\\"+u[n]})),t.forEach((function(n,t){n&&(v+=i[t](n))}))})),v="try{".concat(v+="');","}catch(e){console.info(e)}"),t&&(v="with(".concat(o,"){").concat(v,"}")),v="".concat(p,".start();").concat(v,"return ").concat(p,".end();"),v+="\n//# sourceURL=".concat(e);var d=null;try{(d=new Function(o,p,l,v)).source="(function(".concat(o,",").concat(p,",").concat(l,"){\n").concat(v,"\n})")}catch(n){throw n.filename=e,n.source=v,n}return d}},A=function(n){return window.fetch(n).then((function(n){return n.text()}))},R=function(t){return new Promise((function(e,r){n.readFile(t,(function(n,t){n?r(n):e(t.toString())}))}))},L=function(t,e){return n.watch(".",{cwd:t}).on("change",(function(n){e.remove(n)})).on("error",(function(n){console.log("watcher error: "+n)}))},M=function(n,t,e){var o=n.path;n.token;var i=r(n.resolver)?n.resolver:c()?R:A,u=function(n){return i(function(n){return(n=[o,n].join("/")).replace(/\/\//g,"/")}(n))},a=function(n,e){return t.set(e,n),n};return n.watch&&c()&&L(o,t),function(n){if(t.exist(n))return t.resolve(n);var r=u(n).then((function(t){return a(e(t,n),n)}));return a(r,n)}},P=function(n){return Promise.all(n).then((function(n){return n.join("")}))},U=function(){var n=[],t=[];function e(n){t.push(n)}return e.start=function(){t=[]},e.backup=function(){n.push(t.concat()),t=[]},e.restore=function(){var e=t.concat();return t=n.pop(),P(e)},e.error=function(n){throw n},e.end=function(){return P(t)},e};var C,T,q,_,N,D=(T={},q={},_=function(n,t){var e=n.split(".").pop();return e!==t&&(n=[n,t].join(".")),n},N={element:B,output:function(n,t){return N.template(n).then((function(n){return n.call(t,t,t.getBuffer(),p)}))},render:function(n,t){var e=_(n,T.extension),r=new N.scope(t);return N.output(e,r).then((function(n){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),e=r.clone();return N.render(t,e)}return n}))},require:function(n){var t=_(n,T.extension),e=new N.scope({});return N.output(t,e).then((function(){return e.getMacro()}))},helpers:function(n){d(q,n=n||{}),N.scope.helpers(n)},configure:function(n){return T.export=e(o,t.export,n.export),T.path=e(o,t.path,n.path),T.resolver=e(r,t.resolver,n.resolver),T.extension=e(o,t.extension,n.extension),T.withObject=e(i,t.withObject,n.withObject),T.token=d({},t.token,n.token),T.vars=d({},t.vars,n.vars),N.scope=function(n,t){var e=n.vars,i=e.EXTEND,c=e.LAYOUT,u=e.BLOCKS,a=e.BUFFER,f=e.MACRO;function s(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),d(this,n)}return s.helpers=function(n){d(s.prototype,n)},s.property=function(n,t){Object.defineProperty(s.prototype,n,t)},s.method=function(n,t){Object.defineProperty(s.prototype,n,{value:t,writable:!1,configurable:!1,enumerable:!1})},s.property(a,{value:U(),writable:!1,configurable:!1,enumerable:!1}),s.property(u,{value:{},writable:!0,configurable:!1,enumerable:!1}),s.property(f,{value:{},writable:!0,configurable:!1,enumerable:!1}),s.property(c,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s.property(i,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s.method("initBlocks",(function(){this[u]={}})),s.method("initMacro",(function(){this[f]={}})),s.method("getMacro",(function(){return this[f]})),s.method("getBuffer",(function(){return this[a]})),s.method("getBlocks",(function(){return this[u]})),s.method("setExtend",(function(n){this[i]=n})),s.method("getExtend",(function(){return this[i]})),s.method("setLayout",(function(n){this[c]=n})),s.method("getLayout",(function(){return this[c]})),s.method("clone",(function(n){var t=[c,i,a];return!0===n&&t.push(u),b(this,t)})),s.method("extend",(function(n){this.setExtend(!0),this.setLayout(n)})),s.method("echo",(function(){var n=this.getBuffer();[].slice.call(arguments).forEach((function(t){n(t)}))})),s.method("fn",(function(n){var t=this.getBuffer(),e=this;return function(){return t.backup(),r(n)&&n.apply(e,arguments),t.restore()}})),s.method("get",(function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return y(r,o)?r[o]:t})),s.method("set",(function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return this.getExtend()&&y(r,o)?r[o]:r[o]=t})),s.method("macro",(function(n,t){var e=this.getMacro(),r=this.fn(t),o=this;e[n]=function(){return o.echo(r.apply(void 0,arguments))}})),s.method("call",(function(n){var t=this.getMacro()[n],e=[].slice.call(arguments,1);if(r(t))return t.apply(t,e)})),s.method("block",(function(n,t){var e=this,r=this.getBlocks();if(r[n]=r[n]||[],r[n].push(this.fn(t)),!this.getExtend()){var o=Object.assign([],r[n]),i=function(){return o.shift()};this.echo(i()(function n(){var t=i();return t?function(){e.echo(t(n()))}:m}()))}})),s.method("include",(function(n,t,e){var r=!1===e?{}:this.clone(!0),o=d(r,t||{}),i=this.render(n,o);this.echo(i)})),s.method("use",(function(n,t){var e=this.require(n);this.echo(w(e,(function(n){var e=this.getMacro();g(n,(function(n,r){e[[t,r].join(".")]=n}))}),this))})),s.method("async",(function(n,t){this.echo(w(n,(function(n){return this.fn(t)(n)}),this))})),s.method("el",(function(n,t,e){r(e)&&(e=this.fn(e)()),this.echo(w(e,(function(e){return B(n,t,e)}),this))})),s.method("each",(function(n,t){o(n)&&(n=this.get(n,[])),g(n,t)})),s.helpers(t),s}(T,q),N.compile=S(T),N.wrapper=function(n){var t=n.export;return function(n){var e="(function(o){\n";return n.forEach((function(n){e+="o["+JSON.stringify(n.name)+"]="+String(n.content)+"\n"})),e+='})(window["'+t+'"] = window["'+t+'"] || {});\n'}}(T),N.cache=function(n){var t=n.export,e={};return{preload:function(){return!1===c()&&this.load(window[t]),this},exist:function(n){return y(e,n)},get:function(n){return e[n]},remove:function(n){delete e[n]},resolve:function(n){return Promise.resolve(this.get(n))},set:function(n,t){return e[n]=t,this},load:function(n){return d(e,n),this}}.preload()}(T),N.template=M(T,N.cache,N.compile),N},__express:function(c,u,a){r(u)&&(a=u,u={});var f=d({},(u=u||{}).settings),s=e(o,f.views,t.path),h=e(i,f["view cache"],t.cache),l=d({},f["view options"]),p=n.relative(s,c);return l.path=s,l.cache=h,N.configure(l),N.render(p,u).then((function(n){a(null,n)})).catch((function(n){a(n)}))}},N.configure(C||{}),N.helpers({require:function(n){return N.require(n,this)},render:function(n,t){return N.render(n,t)}}),N);return D}));
1
+ !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).ejs=t()}(this,(function(){"use strict";var n={},t={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",withObject:!0,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},e=function(){var n=[].slice.call(arguments),t=n.shift();return n.filter(t).pop()},r=function(n){return"function"==typeof n},o=function(n){return"string"==typeof n},i=function(n){return"boolean"==typeof n},c=new Function("try {return this===global;}catch(e){return false;}"),u={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},f=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},s=f(a),h=f(u),l=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+n).replace(s,(function(n){return a[n]}))},p=function(n,t,e){return null==(e=n)?"":t?l(e):e},v=function(n,t){var e=n,r=t.split("."),o=r.pop();return r.forEach((function(n){e=e[n]=e[n]||{}})),[e,o]},d=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];var r=t.shift();return t.filter((function(n){return n})).reduce((function(n,t){return Object.assign(n,t)}),r)},m=function(){},g=function(n,t){var e;for(e in n)y(n,e)&&t(n[e],e,n)},b=function(n,t){return function(n,t,e){var r=n instanceof Array,o=r?[]:{};return g(n,(function(n,e,i){var c=t(n,e,i);void 0!==c&&(r?o.push(c):o[e]=c)})),o}(n,(function(n,e){if(-1===t.indexOf(e))return n}))},w=function(n,t,e){return Promise.resolve(n).then(t.bind(e))},y=function(n,t){return n&&n.hasOwnProperty(t)},x=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],E=" ",j='"',F="/",O="<",B=">";function k(n,t,e){var r=[],o=-1===x.indexOf(n),i=function(n,t,e){var r=[];return g(n,(function(n,e,o){var i=t(n,e,o);void 0!==i&&r.push(i)})),r}(t,(function(n,t){if(null!=n)return[l(t),[j,l(n),j].join("")].join("=")})).join(E);return r.push([O,n,E,i,B].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([O,F,n,B].join("")),r.join("")}var R=[{symbol:"-",format:function(n){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(n,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(n){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(n,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(n){return"')\n/**".concat(n,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(n){return"')\n".concat(n.trim(),"\n").concat(this.BUFFER,"('")}}],$=function(n){var t=n.withObject,e=n.token,r=n.vars,o=[],i=[],c={match:"[ \\t]*",start:[e.start,"_"],end:["_",e.end]};R.forEach((function(n){o.push(e.start.concat(n.symbol).concat(e.regex).concat(e.end)),i.push(n.format.bind(r))}));var a=new RegExp(o.join("|").concat("|$"),"g"),f=new RegExp([c.match,c.start].join(""),"gm"),s=new RegExp([c.end,c.match].join(""),"gm");return function(n,e){var o=r.SCOPE,l=r.SAFE,p=r.BUFFER;n=(n=n.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(f,c.start).replace(s,c.end);var v="".concat(p,"('");!function(n,t,e){var r=0;t.replace(n,(function(){var n=[].slice.call(arguments,0,-1),t=n.pop(),o=n.shift();return e(n,r,t),r=t+o.length,o}))}(a,n,(function(t,e,r){v+=(""+n.slice(e,r)).replace(h,(function(n){return"\\"+u[n]})),t.forEach((function(n,t){n&&(v+=i[t](n))}))})),v="try{".concat(v+="');","}catch(e){console.info(e)}"),t&&(v="with(".concat(o,"){").concat(v,"}")),v="".concat(p,".start();").concat(v,"return ").concat(p,".end();"),v+="\n//# sourceURL=".concat(e);var d=null;try{(d=new Function(o,p,l,v)).source="(function(".concat(o,",").concat(p,",").concat(l,"){\n").concat(v,"\n})")}catch(n){throw n.filename=e,n.source=v,n}return d}},S=function(n){return window.fetch(n).then((function(n){return n.text()}))},U=function(t){return new Promise((function(e,r){n.readFile(t,(function(n,t){n?r(n):e(t.toString())}))}))},A=function(t,e){return n.watch(".",{cwd:t}).on("change",(function(n){e.remove(n)})).on("error",(function(n){console.log("watcher error: "+n)}))},L=function(n,t,e){var o=n.path;n.token;var i=r(n.resolver)?n.resolver:c()?U:S,u=function(n){return i(function(n){return(n=[o,n].join("/")).replace(/\/\//g,"/")}(n))},a=function(n,e){return t.set(e,n),n};return n.watch&&c()&&A(o,t),function(n){if(t.exist(n))return t.resolve(n);var r=u(n).then((function(t){return a(e(t,n),n)}));return a(r,n)}},M=function(n){return Promise.all(n).then((function(n){return n.join("")}))},P=function(){var n=[],t=[];function e(n){t.push(n)}return e.start=function(){t=[]},e.backup=function(){n.push(t.concat()),t=[]},e.restore=function(){var e=t.concat();return t=n.pop(),M(e)},e.error=function(n){throw n},e.end=function(){return M(t)},e};var C,T,q,_,N,D=(T={},q={},_=function(n,t){var e=n.split(".").pop();return e!==t&&(n=[n,t].join(".")),n},N={safeValue:p,element:k,output:function(n,t){return N.template(n).then((function(n){return n.call(t,t,t.getBuffer(),p)}))},render:function(n,t){var e=_(n,T.extension),r=new N.scope(t);return N.output(e,r).then((function(n){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),e=r.clone();return N.render(t,e)}return n}))},require:function(n){var t=_(n,T.extension),e=new N.scope({});return N.output(t,e).then((function(){return e.getMacro()}))},helpers:function(n){d(q,n=n||{}),N.scope.helpers(n)},configure:function(n){return T.export=e(o,t.export,n.export),T.path=e(o,t.path,n.path),T.resolver=e(r,t.resolver,n.resolver),T.extension=e(o,t.extension,n.extension),T.withObject=e(i,t.withObject,n.withObject),T.token=d({},t.token,n.token),T.vars=d({},t.vars,n.vars),N.scope=function(n,t){var e=n.vars,i=e.EXTEND,c=e.LAYOUT,u=e.BLOCKS,a=e.BUFFER,f=e.MACRO;function s(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),d(this,n)}return s.helpers=function(n){d(s.prototype,n)},s.property=function(n,t){Object.defineProperty(s.prototype,n,t)},s.method=function(n,t){Object.defineProperty(s.prototype,n,{value:t,writable:!1,configurable:!1,enumerable:!1})},s.property(a,{value:P(),writable:!1,configurable:!1,enumerable:!1}),s.property(u,{value:{},writable:!0,configurable:!1,enumerable:!1}),s.property(f,{value:{},writable:!0,configurable:!1,enumerable:!1}),s.property(c,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s.property(i,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s.method("initBlocks",(function(){this[u]={}})),s.method("initMacro",(function(){this[f]={}})),s.method("getMacro",(function(){return this[f]})),s.method("getBuffer",(function(){return this[a]})),s.method("getBlocks",(function(){return this[u]})),s.method("setExtend",(function(n){this[i]=n})),s.method("getExtend",(function(){return this[i]})),s.method("setLayout",(function(n){this[c]=n})),s.method("getLayout",(function(){return this[c]})),s.method("clone",(function(n){var t=[c,i,a];return!0===n&&t.push(u),b(this,t)})),s.method("extend",(function(n){this.setExtend(!0),this.setLayout(n)})),s.method("echo",(function(){var n=this.getBuffer();[].slice.call(arguments).forEach((function(t){n(t)}))})),s.method("fn",(function(n){var t=this.getBuffer(),e=this;return function(){return t.backup(),r(n)&&n.apply(e,arguments),t.restore()}})),s.method("get",(function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return y(r,o)?r[o]:t})),s.method("set",(function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return this.getExtend()&&y(r,o)?r[o]:r[o]=t})),s.method("macro",(function(n,t){var e=this.getMacro(),r=this.fn(t),o=this;e[n]=function(){return o.echo(r.apply(void 0,arguments))}})),s.method("call",(function(n){var t=this.getMacro()[n],e=[].slice.call(arguments,1);if(r(t))return t.apply(t,e)})),s.method("block",(function(n,t){var e=this,r=this.getBlocks();if(r[n]=r[n]||[],r[n].push(this.fn(t)),!this.getExtend()){var o=Object.assign([],r[n]),i=function(){return o.shift()};this.echo(i()(function n(){var t=i();return t?function(){e.echo(t(n()))}:m}()))}})),s.method("include",(function(n,t,e){var r=!1===e?{}:this.clone(!0),o=d(r,t||{}),i=this.render(n,o);this.echo(i)})),s.method("use",(function(n,t){var e=this.require(n);this.echo(w(e,(function(n){var e=this.getMacro();g(n,(function(n,r){e[[t,r].join(".")]=n}))}),this))})),s.method("async",(function(n,t){this.echo(w(n,(function(n){return this.fn(t)(n)}),this))})),s.method("el",(function(n,t,e){r(e)&&(e=this.fn(e)()),this.echo(w(e,(function(e){return k(n,t,e)}),this))})),s.method("each",(function(n,t){o(n)&&(n=this.get(n,[])),g(n,t)})),s.helpers(t),s}(T,q),N.compile=$(T),N.wrapper=function(n){var t=n.export;return function(n){var e="(function(o){\n";return n.forEach((function(n){e+="o["+JSON.stringify(n.name)+"]="+String(n.content)+"\n"})),e+='})(window["'+t+'"] = window["'+t+'"] || {});\n'}}(T),N.cache=function(n){var t=n.export,e={};return{preload:function(){return!1===c()&&this.load(window[t]),this},exist:function(n){return y(e,n)},get:function(n){return e[n]},remove:function(n){delete e[n]},resolve:function(n){return Promise.resolve(this.get(n))},set:function(n,t){return e[n]=t,this},load:function(n){return d(e,n),this}}.preload()}(T),N.template=L(T,N.cache,N.compile),N},__express:function(c,u,a){r(u)&&(a=u,u={});var f=d({},(u=u||{}).settings),s=e(o,f.views,t.path),h=e(i,f["view cache"],t.cache),l=d({},f["view options"]),p=n.relative(s,c);return l.path=s,l.cache=h,N.configure(l),N.render(p,u).then((function(n){a(null,n)})).catch((function(n){a(n)}))}},N.configure(C||{}),N.helpers({require:function(n){return N.require(n,this)},render:function(n,t){return N.render(n,t)}}),N);return D}));
package/dist/ejs.mjs CHANGED
@@ -213,25 +213,25 @@ const tags = [
213
213
  {
214
214
  symbol: '-',
215
215
  format(value) {
216
- return `'+\n${this.SAFE}(${value},1)+\n'`
216
+ return `')\n${this.BUFFER}(${this.SAFE}(${value},1))\n${this.BUFFER}('`
217
217
  },
218
218
  },
219
219
  {
220
220
  symbol: '=',
221
221
  format(value) {
222
- return `'+\n${this.SAFE}(${value})+\n'`
222
+ return `')\n${this.BUFFER}(${this.SAFE}(${value}))\n${this.BUFFER}('`
223
223
  },
224
224
  },
225
225
  {
226
226
  symbol: '#',
227
227
  format(value) {
228
- return `'+\n/**${value}**/+\n'`
228
+ return `')\n/**${value}**/\n${this.BUFFER}('`
229
229
  },
230
230
  },
231
231
  {
232
232
  symbol: '',
233
233
  format(value) {
234
- return `')\n${value}\n${this.BUFFER}('`
234
+ return `')\n${value.trim()}\n${this.BUFFER}('`
235
235
  },
236
236
  },
237
237
  ];
@@ -673,6 +673,7 @@ function init(options) {
673
673
  return path
674
674
  };
675
675
  const view = {
676
+ safeValue,
676
677
  element,
677
678
  output(path, scope) {
678
679
  return view.template(path).then(function (template) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@kosatyi/ejs",
3
3
  "description": "EJS Templates",
4
4
  "homepage": "https://github.com/kosatyi/ejs",
5
- "version": "0.0.22",
5
+ "version": "0.0.24",
6
6
  "main": "dist/ejs.cjs",
7
7
  "module": "dist/ejs.mjs",
8
8
  "browser": "dist/ejs.js",