@kosatyi/ejs 0.0.10 → 0.0.12-alpha.0
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 +30 -45
- package/dist/ejs.js +30 -45
- package/dist/ejs.min.js +1 -1
- package/dist/ejs.mjs +64 -59
- package/package.json +1 -1
package/dist/ejs.cjs
CHANGED
|
@@ -111,7 +111,6 @@ var extend = function extend() {
|
|
|
111
111
|
return Object.assign(target, source);
|
|
112
112
|
}, target);
|
|
113
113
|
};
|
|
114
|
-
var noop = function noop() {};
|
|
115
114
|
var each = function each(object, callback) {
|
|
116
115
|
var prop;
|
|
117
116
|
|
|
@@ -461,7 +460,10 @@ var Scope = function Scope(config, methods) {
|
|
|
461
460
|
|
|
462
461
|
function Scope() {
|
|
463
462
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
463
|
+
this.setBlocks({});
|
|
464
464
|
extend(this, data);
|
|
465
|
+
this.setLayout(false);
|
|
466
|
+
this.setExtend(false);
|
|
465
467
|
}
|
|
466
468
|
/**
|
|
467
469
|
*
|
|
@@ -473,27 +475,6 @@ var Scope = function Scope(config, methods) {
|
|
|
473
475
|
writable: false,
|
|
474
476
|
configurable: false,
|
|
475
477
|
enumerable: false
|
|
476
|
-
}), _defineProperty(_Object$definePropert, BLOCKS, {
|
|
477
|
-
value: {},
|
|
478
|
-
writable: false,
|
|
479
|
-
configurable: false,
|
|
480
|
-
enumerable: false
|
|
481
|
-
}), _defineProperty(_Object$definePropert, EXTEND, {
|
|
482
|
-
value: false,
|
|
483
|
-
writable: true,
|
|
484
|
-
configurable: false,
|
|
485
|
-
enumerable: false
|
|
486
|
-
}), _defineProperty(_Object$definePropert, LAYOUT, {
|
|
487
|
-
value: false,
|
|
488
|
-
writable: true,
|
|
489
|
-
configurable: false,
|
|
490
|
-
enumerable: false
|
|
491
|
-
}), _defineProperty(_Object$definePropert, "setBuffer", {
|
|
492
|
-
value: function value(_value) {
|
|
493
|
-
this[BUFFER] = _value;
|
|
494
|
-
},
|
|
495
|
-
writable: false,
|
|
496
|
-
configurable: false
|
|
497
478
|
}), _defineProperty(_Object$definePropert, "getBuffer", {
|
|
498
479
|
value: function value() {
|
|
499
480
|
return this[BUFFER];
|
|
@@ -501,8 +482,8 @@ var Scope = function Scope(config, methods) {
|
|
|
501
482
|
writable: false,
|
|
502
483
|
configurable: false
|
|
503
484
|
}), _defineProperty(_Object$definePropert, "setBlocks", {
|
|
504
|
-
value: function value(
|
|
505
|
-
this[BLOCKS] =
|
|
485
|
+
value: function value(_value) {
|
|
486
|
+
this[BLOCKS] = _value;
|
|
506
487
|
},
|
|
507
488
|
writable: false,
|
|
508
489
|
configurable: false
|
|
@@ -513,8 +494,8 @@ var Scope = function Scope(config, methods) {
|
|
|
513
494
|
writable: false,
|
|
514
495
|
configurable: false
|
|
515
496
|
}), _defineProperty(_Object$definePropert, "setExtend", {
|
|
516
|
-
value: function value(
|
|
517
|
-
this[EXTEND] =
|
|
497
|
+
value: function value(_value2) {
|
|
498
|
+
this[EXTEND] = _value2;
|
|
518
499
|
},
|
|
519
500
|
writable: false,
|
|
520
501
|
configurable: false
|
|
@@ -599,7 +580,9 @@ var Scope = function Scope(config, methods) {
|
|
|
599
580
|
return echo === true ? this.echo(result) : result;
|
|
600
581
|
}.bind(this);
|
|
601
582
|
|
|
602
|
-
macro.
|
|
583
|
+
macro.__context = this;
|
|
584
|
+
macro.__source = callback;
|
|
585
|
+
macro.__layout = this.getLayout();
|
|
603
586
|
return macro;
|
|
604
587
|
},
|
|
605
588
|
|
|
@@ -731,24 +714,26 @@ var Scope = function Scope(config, methods) {
|
|
|
731
714
|
*/
|
|
732
715
|
block: function block(name, callback) {
|
|
733
716
|
var blocks = this.getBlocks();
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
717
|
+
blocks[name] = blocks[name] || [];
|
|
718
|
+
blocks[name].push(this.macro(callback));
|
|
719
|
+
|
|
720
|
+
if (this.getExtend() === false) {
|
|
721
|
+
var list = blocks[name];
|
|
722
|
+
|
|
723
|
+
var _callback = function _callback() {
|
|
724
|
+
var parent = list.shift();
|
|
725
|
+
|
|
726
|
+
if (parent) {
|
|
727
|
+
var context = parent.__context;
|
|
728
|
+
return function () {
|
|
729
|
+
context.echo(parent(_callback()));
|
|
730
|
+
};
|
|
731
|
+
} else {
|
|
732
|
+
return function () {};
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
this.echo(list.shift()(_callback()));
|
|
752
737
|
}
|
|
753
738
|
},
|
|
754
739
|
|
package/dist/ejs.js
CHANGED
|
@@ -107,7 +107,6 @@
|
|
|
107
107
|
return Object.assign(target, source);
|
|
108
108
|
}, target);
|
|
109
109
|
};
|
|
110
|
-
var noop = function noop() {};
|
|
111
110
|
var each = function each(object, callback) {
|
|
112
111
|
var prop;
|
|
113
112
|
|
|
@@ -457,7 +456,10 @@
|
|
|
457
456
|
|
|
458
457
|
function Scope() {
|
|
459
458
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
459
|
+
this.setBlocks({});
|
|
460
460
|
extend(this, data);
|
|
461
|
+
this.setLayout(false);
|
|
462
|
+
this.setExtend(false);
|
|
461
463
|
}
|
|
462
464
|
/**
|
|
463
465
|
*
|
|
@@ -469,27 +471,6 @@
|
|
|
469
471
|
writable: false,
|
|
470
472
|
configurable: false,
|
|
471
473
|
enumerable: false
|
|
472
|
-
}), _defineProperty(_Object$definePropert, BLOCKS, {
|
|
473
|
-
value: {},
|
|
474
|
-
writable: false,
|
|
475
|
-
configurable: false,
|
|
476
|
-
enumerable: false
|
|
477
|
-
}), _defineProperty(_Object$definePropert, EXTEND, {
|
|
478
|
-
value: false,
|
|
479
|
-
writable: true,
|
|
480
|
-
configurable: false,
|
|
481
|
-
enumerable: false
|
|
482
|
-
}), _defineProperty(_Object$definePropert, LAYOUT, {
|
|
483
|
-
value: false,
|
|
484
|
-
writable: true,
|
|
485
|
-
configurable: false,
|
|
486
|
-
enumerable: false
|
|
487
|
-
}), _defineProperty(_Object$definePropert, "setBuffer", {
|
|
488
|
-
value: function value(_value) {
|
|
489
|
-
this[BUFFER] = _value;
|
|
490
|
-
},
|
|
491
|
-
writable: false,
|
|
492
|
-
configurable: false
|
|
493
474
|
}), _defineProperty(_Object$definePropert, "getBuffer", {
|
|
494
475
|
value: function value() {
|
|
495
476
|
return this[BUFFER];
|
|
@@ -497,8 +478,8 @@
|
|
|
497
478
|
writable: false,
|
|
498
479
|
configurable: false
|
|
499
480
|
}), _defineProperty(_Object$definePropert, "setBlocks", {
|
|
500
|
-
value: function value(
|
|
501
|
-
this[BLOCKS] =
|
|
481
|
+
value: function value(_value) {
|
|
482
|
+
this[BLOCKS] = _value;
|
|
502
483
|
},
|
|
503
484
|
writable: false,
|
|
504
485
|
configurable: false
|
|
@@ -509,8 +490,8 @@
|
|
|
509
490
|
writable: false,
|
|
510
491
|
configurable: false
|
|
511
492
|
}), _defineProperty(_Object$definePropert, "setExtend", {
|
|
512
|
-
value: function value(
|
|
513
|
-
this[EXTEND] =
|
|
493
|
+
value: function value(_value2) {
|
|
494
|
+
this[EXTEND] = _value2;
|
|
514
495
|
},
|
|
515
496
|
writable: false,
|
|
516
497
|
configurable: false
|
|
@@ -595,7 +576,9 @@
|
|
|
595
576
|
return echo === true ? this.echo(result) : result;
|
|
596
577
|
}.bind(this);
|
|
597
578
|
|
|
598
|
-
macro.
|
|
579
|
+
macro.__context = this;
|
|
580
|
+
macro.__source = callback;
|
|
581
|
+
macro.__layout = this.getLayout();
|
|
599
582
|
return macro;
|
|
600
583
|
},
|
|
601
584
|
|
|
@@ -727,24 +710,26 @@
|
|
|
727
710
|
*/
|
|
728
711
|
block: function block(name, callback) {
|
|
729
712
|
var blocks = this.getBlocks();
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
713
|
+
blocks[name] = blocks[name] || [];
|
|
714
|
+
blocks[name].push(this.macro(callback));
|
|
715
|
+
|
|
716
|
+
if (this.getExtend() === false) {
|
|
717
|
+
var list = blocks[name];
|
|
718
|
+
|
|
719
|
+
var _callback = function _callback() {
|
|
720
|
+
var parent = list.shift();
|
|
721
|
+
|
|
722
|
+
if (parent) {
|
|
723
|
+
var context = parent.__context;
|
|
724
|
+
return function () {
|
|
725
|
+
context.echo(parent(_callback()));
|
|
726
|
+
};
|
|
727
|
+
} else {
|
|
728
|
+
return function () {};
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
this.echo(list.shift()(_callback()));
|
|
748
733
|
}
|
|
749
734
|
},
|
|
750
735
|
|
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:{template:"ejs",module:"mjs"},vars:{EXTEND:"$$$",BUFFER:"$$a",OUTPUT:"$$i",LAYOUT:"$$l",MACROS:"$$m",PRINT:"$$j",BLOCKS:"$$b",ERROR:"$$e",SCOPE:"$$s",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},u=new Function("try {return this===global;}catch(e){return false;}"),c={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},a={"&":"&","<":"<",">":">",'"':""","'":"'"},
|
|
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:{template:"ejs",module:"mjs"},vars:{EXTEND:"$$$",BUFFER:"$$a",OUTPUT:"$$i",LAYOUT:"$$l",MACROS:"$$m",PRINT:"$$j",BLOCKS:"$$b",ERROR:"$$e",SCOPE:"$$s",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},u=new Function("try {return this===global;}catch(e){return false;}"),c={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},a={"&":"&","<":"<",">":">",'"':""","'":"'"},s=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},f=s(a),l=s(c),h=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+n).replace(f,(function(n){return a[n]}))},p=function(n,t,e){return null==(e=n)?"":t?h(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)},g=function(n,t){var e;for(e in n)b(n,e)&&t(n[e],e,n)},m=function(n,t){return function(n,t,e){var r=n instanceof Array,o=r?[]:{};return g(n,(function(n,e,i){var u=t(n,e,i);void 0!==u&&(r?o.push(u):o[e]=u)})),o}(n,(function(n,e){if(-1===t.indexOf(e))return n}))},b=function(n,t){return n&&n.hasOwnProperty(t)},w=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],x=" ",y='"',E="/",j="<",$=">";function O(n,t,e){var r=[],o=-1===w.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[h(t),[y,h(n),y].join("")].join("=")})).join(x);return r.push([j,n,x,i,$].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([j,E,n,$].join("")),r.join("")}var k=[{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,"('")}}],F=function(n){var t=n.token,e=n.vars,r=n.extension.module,o=[],i=[],u={match:"[ \\t]*",start:[t.start,"_"],end:["_",t.end]};k.forEach((function(n){o.push(t.start.concat(n.symbol).concat(t.regex).concat(t.end)),i.push(n.format.bind(e))}));var a=new RegExp(o.join("|").concat("|$"),"g"),s=new RegExp([u.match,u.start].join(""),"gm"),f=new RegExp([u.end,u.match].join(""),"gm");return function(n,o){var h=e.SCOPE,p=e.SAFE,v=e.BUFFER,d=o.split(".").pop();n=(n=n.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(s,u.start).replace(f,u.end),d===r&&(n=[t.start,n,t.end].join("\n"));var g="".concat(v,"('");!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){g+=(""+n.slice(e,r)).replace(l,(function(n){return"\\"+c[n]})),t.forEach((function(n,t){n&&(g+=i[t](n))}))})),g+="');",g="with(".concat(h,"){").concat(g,"}"),g="".concat(v,".start();").concat(g,"return ").concat(v,".end();"),g+="\n//# sourceURL=".concat(o);var m=null;try{(m=new Function(h,v,p,g)).source="(function(".concat(h,",").concat(v,",").concat(p,"){\n").concat(g,"\n})")}catch(n){throw n.filename=o,n.source=g,n}return m}},R=function(n){return window.fetch(n).then((function(n){return n.text()}))},B=function(t){return new Promise((function(e,r){n.readFile(t,(function(n,t){n?r(n):e(t.toString())}))}))},S=function(t,e){return n.watch(".",{cwd:t}).on("change",(function(n){e.remove(n)})).on("error",(function(n){console.log("watcher error: "+n)}))},_=function(n,t,e){var o=n.path;n.token;var i=r(n.resolver)?n.resolver:u()?B:R,c=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&&u()&&S(o,t),function(n){if(t.exist(n))return t.resolve(n);var r=c(n).then((function(t){return a(e(t,n),n)}));return a(r,n)}};function A(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}var L=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(),L(e)},e.end=function(){return L(t)},e},T=function(n,t){var e,i=n.vars,u=i.EXTEND,c=i.MACROS,a=i.LAYOUT,s=i.BLOCKS,f=i.BUFFER;function l(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setBlocks({}),d(this,n),this.setLayout(!1),this.setExtend(!1)}return Object.defineProperties(l.prototype,(A(e={},f,{value:P(),writable:!1,configurable:!1,enumerable:!1}),A(e,"getBuffer",{value:function(){return this[f]},writable:!1,configurable:!1}),A(e,"setBlocks",{value:function(n){this[s]=n},writable:!1,configurable:!1}),A(e,"getBlocks",{value:function(){return this[s]},writable:!1,configurable:!1}),A(e,"setExtend",{value:function(n){this[u]=n},writable:!1,configurable:!1}),A(e,"getExtend",{value:function(){return this[u]},writable:!1,configurable:!1}),A(e,"setLayout",{value:function(n){this[a]=n},writable:!1,configurable:!1}),A(e,"getLayout",{value:function(){return this[a]},writable:!1,configurable:!1}),e)),l.helpers=function(n){d(l.prototype,n)},l.helpers(t),l.helpers({clone:function(n){var t=[a,u,c,f];return!0===n&&t.push(s),m(this,t)},echo:function(){var n=this.getBuffer(),t=[].slice.call(arguments);t.forEach((function(t){n(t)}))},macro:function(n,t){var e=this.getBuffer(),o=function(){e.backup(),r(n)&&n.apply(this,arguments);var o=e.restore();return!0===t?this.echo(o):o}.bind(this);return o.__context=this,o.__source=n,o.__layout=this.getLayout(),o},resolve:function(n,t){return Promise.resolve(n).then(t.bind(this))},async:function(n,t){var e=this;this.echo(this.resolve(n,(function(n){return e.macro(t)(n)})))},node:O,element:function(n,t,e){r(e)&&(e=this.macro(e)()),this.echo(this.resolve(e,(function(e){return O(n,t,e)})))},component:function(n,t){t=function(n){var t=d({},n.props);return{element:O,create:n.create,render:function(n){return this.create(d({},t,n))}}}(t),this.set(n,function(n){this.echo(t.render(n))}.bind(this))},get:function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return b(r,o)?r[o]:t},set:function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();if(this.getExtend()&&b(r,o))return r[o];r[o]=t},call:function(n){var t=[].slice.call(arguments,1),e=v(this,n),o=e.shift(),i=e.pop();if(r(o[i]))return o[i].apply(o,t)},each:function(n,t){o(n)&&(n=this.get(n,[])),g(n,t)},extend:function(n){this.setExtend(!0),this.setLayout(n)},block:function(n,t){var e=this.getBlocks();if(e[n]=e[n]||[],e[n].push(this.macro(t)),!1===this.getExtend()){var r=e[n];this.echo(r.shift()(function n(){var t=r.shift();if(t){var e=t.__context;return function(){e.echo(t(n()))}}return function(){}}()))}},include:function(n,t,e){var r=!1===e?{}:this.clone(!0),o=d(r,t||{}),i=this.render(n,o);this.echo(i)},use:function(n){var t=this,e=this.require(n);return this.echo(e),{as:function(n){return e.then((function(e){t.set(n,e)})),this}}},from:function(n){var t=this,e=this.require(n);return this.echo(e),{use:function(){var n=[].slice.call(arguments);return e.then((function(e){n.forEach((function(n){t.set(n,e[n])}))})),this}}}}),l};var U,q,C,N,D,K=(q={},C={},N=function(n,t){var e=n.split(".").pop();return e!==t&&(n=[n,t].join(".")),n},D={element:O,output:function(n,t){return D.template(n).then((function(n){return n.call(t,t,t.getBuffer(),p)}))},render:function(n,t){var e=N(n,q.extension.template),r=new D.scope(t);return D.output(e,r).then((function(n){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),e=r.clone();return D.render(t,e)}return n}))},require:function(n){var t=N(n,q.extension.module),e=new D.scope({});return D.output(t,e).then((function(){return e.clone(!0)}))},helpers:function(n){d(C,n=n||{}),D.scope.helpers(n)},configure:function(n){return q.export=e(o,t.export,n.export),q.path=e(o,t.path,n.path),q.resolver=e(r,t.resolver,n.resolver),q.extension=d({},t.extension,n.extension),q.token=d({},t.token,n.token),q.vars=d({},t.vars,n.vars),D.scope=T(q,C),D.compile=F(q),D.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'}}(q),D.cache=function(n){var t=n.export,e={};return{preload:function(){return!1===u()&&this.load(window[t]),this},exist:function(n){return b(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()}(q),D.template=_(q,D.cache,D.compile),D},__express:function(u,c,a){r(c)&&(a=c,c={});var s=d({},(c=c||{}).settings),f=e(o,s.views,t.path),l=e(i,s["view cache"],t.cache),h=d({},s["view options"]),p=n.relative(f,u);return h.path=f,h.cache=l,D.configure(h),D.render(p,c).then((function(n){a(null,n)})).catch((function(n){a(n)}))}},D.configure(U||{}),D.helpers({require:function(n){return D.require(n,this)},render:function(n,t){return D.render(n,t)}}),D);return K}));
|
package/dist/ejs.mjs
CHANGED
|
@@ -112,8 +112,6 @@ const extend = (...args) => {
|
|
|
112
112
|
}, target)
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
const noop = () => {};
|
|
116
|
-
|
|
117
115
|
const each = (object, callback) => {
|
|
118
116
|
let prop;
|
|
119
117
|
for (prop in object) {
|
|
@@ -447,13 +445,17 @@ const Scope = (config, methods) => {
|
|
|
447
445
|
*
|
|
448
446
|
*/
|
|
449
447
|
const { EXTEND, MACROS, LAYOUT, BLOCKS, BUFFER } = config.vars;
|
|
448
|
+
|
|
450
449
|
/**
|
|
451
450
|
*
|
|
452
451
|
* @param data
|
|
453
452
|
* @constructor
|
|
454
453
|
*/
|
|
455
454
|
function Scope(data = {}) {
|
|
455
|
+
this.setBlocks({});
|
|
456
456
|
extend(this, data);
|
|
457
|
+
this.setLayout(false);
|
|
458
|
+
this.setExtend(false);
|
|
457
459
|
}
|
|
458
460
|
/**
|
|
459
461
|
*
|
|
@@ -463,82 +465,82 @@ const Scope = (config, methods) => {
|
|
|
463
465
|
value: Buffer(),
|
|
464
466
|
writable: false,
|
|
465
467
|
configurable: false,
|
|
466
|
-
enumerable: false
|
|
467
|
-
},
|
|
468
|
-
[BLOCKS]: {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
},
|
|
474
|
-
[EXTEND]: {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
},
|
|
480
|
-
[LAYOUT]: {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
},
|
|
486
|
-
setBuffer: {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
},
|
|
468
|
+
enumerable: false
|
|
469
|
+
},
|
|
470
|
+
// [BLOCKS]: {
|
|
471
|
+
// value: {},
|
|
472
|
+
// writable: true,
|
|
473
|
+
// configurable: false,
|
|
474
|
+
// enumerable: false
|
|
475
|
+
// },
|
|
476
|
+
// [EXTEND]: {
|
|
477
|
+
// value: false,
|
|
478
|
+
// writable: true,
|
|
479
|
+
// configurable: false,
|
|
480
|
+
// enumerable: false
|
|
481
|
+
// },
|
|
482
|
+
// [LAYOUT]: {
|
|
483
|
+
// value: false,
|
|
484
|
+
// writable: true,
|
|
485
|
+
// configurable: false,
|
|
486
|
+
// enumerable: false
|
|
487
|
+
// },
|
|
488
|
+
// setBuffer: {
|
|
489
|
+
// value(value) {
|
|
490
|
+
// this[BUFFER] = value
|
|
491
|
+
// },
|
|
492
|
+
// writable: false,
|
|
493
|
+
// configurable: false
|
|
494
|
+
// },
|
|
493
495
|
getBuffer: {
|
|
494
496
|
value() {
|
|
495
497
|
return this[BUFFER]
|
|
496
498
|
},
|
|
497
499
|
writable: false,
|
|
498
|
-
configurable: false
|
|
500
|
+
configurable: false
|
|
499
501
|
},
|
|
500
502
|
setBlocks: {
|
|
501
503
|
value(value) {
|
|
502
504
|
this[BLOCKS] = value;
|
|
503
505
|
},
|
|
504
506
|
writable: false,
|
|
505
|
-
configurable: false
|
|
507
|
+
configurable: false
|
|
506
508
|
},
|
|
507
509
|
getBlocks: {
|
|
508
510
|
value() {
|
|
509
511
|
return this[BLOCKS]
|
|
510
512
|
},
|
|
511
513
|
writable: false,
|
|
512
|
-
configurable: false
|
|
514
|
+
configurable: false
|
|
513
515
|
},
|
|
514
516
|
setExtend: {
|
|
515
517
|
value(value) {
|
|
516
518
|
this[EXTEND] = value;
|
|
517
519
|
},
|
|
518
520
|
writable: false,
|
|
519
|
-
configurable: false
|
|
521
|
+
configurable: false
|
|
520
522
|
},
|
|
521
523
|
getExtend: {
|
|
522
524
|
value() {
|
|
523
525
|
return this[EXTEND]
|
|
524
526
|
},
|
|
525
527
|
writable: false,
|
|
526
|
-
configurable: false
|
|
528
|
+
configurable: false
|
|
527
529
|
},
|
|
528
530
|
setLayout: {
|
|
529
531
|
value(layout) {
|
|
530
532
|
this[LAYOUT] = layout;
|
|
531
533
|
},
|
|
532
534
|
writable: false,
|
|
533
|
-
configurable: false
|
|
535
|
+
configurable: false
|
|
534
536
|
},
|
|
535
537
|
getLayout: {
|
|
536
538
|
value() {
|
|
537
539
|
return this[LAYOUT]
|
|
538
540
|
},
|
|
539
541
|
writable: false,
|
|
540
|
-
configurable: false
|
|
541
|
-
}
|
|
542
|
+
configurable: false
|
|
543
|
+
}
|
|
542
544
|
});
|
|
543
545
|
|
|
544
546
|
Scope.helpers = (methods) => {
|
|
@@ -571,7 +573,7 @@ const Scope = (config, methods) => {
|
|
|
571
573
|
echo() {
|
|
572
574
|
const buffer = this.getBuffer();
|
|
573
575
|
const params = [].slice.call(arguments);
|
|
574
|
-
params.forEach(function
|
|
576
|
+
params.forEach(function(item) {
|
|
575
577
|
buffer(item);
|
|
576
578
|
});
|
|
577
579
|
},
|
|
@@ -584,7 +586,7 @@ const Scope = (config, methods) => {
|
|
|
584
586
|
*/
|
|
585
587
|
macro(callback, echo) {
|
|
586
588
|
const buffer = this.getBuffer();
|
|
587
|
-
const macro = function
|
|
589
|
+
const macro = function() {
|
|
588
590
|
buffer.backup();
|
|
589
591
|
if (isFunction(callback)) {
|
|
590
592
|
callback.apply(this, arguments);
|
|
@@ -592,7 +594,9 @@ const Scope = (config, methods) => {
|
|
|
592
594
|
const result = buffer.restore();
|
|
593
595
|
return echo === true ? this.echo(result) : result
|
|
594
596
|
}.bind(this);
|
|
595
|
-
macro.
|
|
597
|
+
macro.__context = this;
|
|
598
|
+
macro.__source = callback;
|
|
599
|
+
macro.__layout = this.getLayout();
|
|
596
600
|
return macro
|
|
597
601
|
},
|
|
598
602
|
/**
|
|
@@ -636,7 +640,7 @@ const Scope = (config, methods) => {
|
|
|
636
640
|
instance = Component(instance);
|
|
637
641
|
this.set(
|
|
638
642
|
namespace,
|
|
639
|
-
function
|
|
643
|
+
function(props) {
|
|
640
644
|
this.echo(instance.render(props));
|
|
641
645
|
}.bind(this)
|
|
642
646
|
);
|
|
@@ -709,21 +713,22 @@ const Scope = (config, methods) => {
|
|
|
709
713
|
*/
|
|
710
714
|
block(name, callback) {
|
|
711
715
|
const blocks = this.getBlocks();
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
}
|
|
716
|
+
blocks[name] = blocks[name] || [];
|
|
717
|
+
blocks[name].push(this.macro(callback));
|
|
718
|
+
if (this.getExtend() === false) {
|
|
719
|
+
const list = blocks[name];
|
|
720
|
+
const callback = function(){
|
|
721
|
+
const parent = list.shift();
|
|
722
|
+
if( parent ) {
|
|
723
|
+
const context = parent.__context;
|
|
724
|
+
return function(){
|
|
725
|
+
context.echo(parent(callback()));
|
|
726
|
+
}
|
|
727
|
+
} else {
|
|
728
|
+
return function(){}
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
this.echo(list.shift()(callback()));
|
|
727
732
|
}
|
|
728
733
|
},
|
|
729
734
|
/**
|
|
@@ -752,7 +757,7 @@ const Scope = (config, methods) => {
|
|
|
752
757
|
scope.set(namespace, exports);
|
|
753
758
|
});
|
|
754
759
|
return this
|
|
755
|
-
}
|
|
760
|
+
}
|
|
756
761
|
}
|
|
757
762
|
},
|
|
758
763
|
/**
|
|
@@ -772,9 +777,9 @@ const Scope = (config, methods) => {
|
|
|
772
777
|
});
|
|
773
778
|
});
|
|
774
779
|
return this
|
|
775
|
-
}
|
|
780
|
+
}
|
|
776
781
|
}
|
|
777
|
-
}
|
|
782
|
+
}
|
|
778
783
|
});
|
|
779
784
|
return Scope
|
|
780
785
|
};
|
package/package.json
CHANGED