squirrelly
Advanced tools
Comparing version 5.0.1 to 5.1.0
@@ -121,6 +121,6 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var funcStr = '' | ||
var helperArray = [] | ||
var helperArray = [] // A list of all 'outstanding' helpers, or unclosed helpers | ||
var helperNumber = -1 | ||
var helperAutoId = 0 | ||
var helperContainsBlocks = {} | ||
var helperAutoId = 0 // Squirrelly automatically generates an ID for helpers that don't have a custom ID | ||
var helperContainsBlocks = {} // If a helper contains any blocks, helperContainsBlocks[helperID] will be set to true | ||
var m | ||
@@ -192,3 +192,3 @@ Object(_regexps__WEBPACK_IMPORTED_MODULE_0__["setup"])() | ||
funcStr += nativeH.blocks[m[9]](parent.id) | ||
lastIndex = _regexps__WEBPACK_IMPORTED_MODULE_0__["regEx"].lastIndex | ||
lastIndex = _regexps__WEBPACK_IMPORTED_MODULE_0__["regEx"].lastIndex // Some native helpers set regEx.lastIndex | ||
} else { | ||
@@ -210,5 +210,7 @@ console.warn("Native helper '%s' doesn't accept that block.", parent.name) | ||
if (m[10] === 'include') { | ||
// This code literally gets the template string up to the include self-closing helper, | ||
// adds the content of the partial, and adds the template string after the include self-closing helper | ||
var preContent = str.slice(0, m.index) | ||
var endContent = str.slice(m.index + m[0].length) | ||
var partialParams = innerParams.replace(/'|"/g, '') | ||
var partialParams = innerParams.replace(/'|"/g, '') // So people can write {{include(mypartial)/}} or {{include('mypartial')/}} | ||
var partialContent = _partials__WEBPACK_IMPORTED_MODULE_3__["default"][partialParams] | ||
@@ -221,6 +223,4 @@ str = preContent + partialContent + endContent | ||
} else { | ||
funcStr += 'tR+=Sqrl.H.' + m[10] + '(' + innerParams + ');' | ||
funcStr += 'tR+=Sqrl.H.' + m[10] + '(' + innerParams + ');' // If it's not native, passing args to a non-native helper | ||
} | ||
} else { | ||
console.error('Err 0') | ||
} | ||
@@ -235,3 +235,3 @@ /* eslint-disable no-inner-declarations */ | ||
if (typeof id !== 'undefined') { | ||
if (/(?:\.\.\/)+/g.test(id)) { | ||
if (/(?:\.\.\/)+/g.test(id)) { // Test if the helper reference is prefixed with ../ | ||
prefix = helperArray[helperNumber - (id.length / 3) - 1].id | ||
@@ -345,2 +345,3 @@ } else { | ||
var defaultFilterCache = { | ||
// This is to prevent having to re-calculate default filters every time you return a filtered string | ||
start: '', | ||
@@ -396,2 +397,4 @@ end: '' | ||
if (filtersArray[i] === 'safe') { | ||
// If 'safe' is one of the filters, set safe to true but don't add Sqrl.F.safe | ||
// Essentially, 'safe' is a flag telling Squirrelly not to autoEscape | ||
safe = true | ||
@@ -432,3 +435,5 @@ continue | ||
__webpack_require__.r(__webpack_exports__); | ||
var helpers = { // For helpers. None included to make it more lightweight | ||
var helpers = { | ||
// No helpers are included by default for the sake of size, | ||
// But there's an example of a helper below | ||
/* | ||
@@ -560,3 +565,3 @@ Date: function (args, content, blocks, options) { | ||
}, | ||
js: { | ||
js: { // The js self-closing helper allows you to inject JavaScript straight into your template function | ||
selfClosing: function (param) { | ||
@@ -609,3 +614,3 @@ return param + ';' | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replaceParamHelpers", function() { return replaceParamHelpers; }); | ||
var initialRegEx = /{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)) *?}}/g | ||
var initialRegEx = /{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)|(?:!--[^]+?--)) *?}}/g | ||
var initialTags = { | ||
@@ -665,3 +670,3 @@ s: '{{', | ||
(?: //choosing global or helper ref | ||
(?:([a-zA-Z_$][\w]* *?(?:[^\s\w\($][^\n]*)*?)) //global reference | ||
(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?)) //global reference | ||
| | ||
@@ -680,2 +685,4 @@ (?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *) //helper reference | ||
(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/) | ||
| //now for comments | ||
(?:!--[^]+?--) | ||
) //end or for each possible tag | ||
@@ -725,2 +732,3 @@ *?}} | ||
// So we can pass Sqrl as a parameter to Render() | ||
@@ -730,3 +738,2 @@ | ||
function defineFilter (name, callback) { | ||
@@ -745,2 +752,4 @@ _filters__WEBPACK_IMPORTED_MODULE_0__["default"][name] = callback | ||
function Render (template, options) { | ||
// If the template parameter is a function, call that function with (options, Sqrl) | ||
// If it's a string, first compile the string and then call the function | ||
if (typeof template === 'function') { | ||
@@ -747,0 +756,0 @@ return template(options, _index__WEBPACK_IMPORTED_MODULE_2__) |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Sqrl=n():e.Sqrl=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var r={};t.r(r),t.d(r,"__express",function(){return $}),t.d(r,"H",function(){return w}),t.d(r,"Compile",function(){return b}),t.d(r,"defineFilter",function(){return S}),t.d(r,"defineHelper",function(){return O}),t.d(r,"defineNativeHelper",function(){return _}),t.d(r,"definePartial",function(){return F}),t.d(r,"Render",function(){return P}),t.d(r,"F",function(){return i}),t.d(r,"setDefaultFilters",function(){return l}),t.d(r,"autoEscaping",function(){return a}),t.d(r,"defaultTags",function(){return g});var i={e:function(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};var t=String(e);return/[&<>"'/]/.test(t)?t.replace(/[&<>"'/]/g,function(e){return n[e]}):t}},o={},u={start:"",end:""};function l(e){if("clear"===e)o={};else for(var n in e)e.hasOwnProperty(n)&&(o[n]=e[n]);!function(){for(var e in u={start:"",end:""},o)o.hasOwnProperty(e)&&o[e]&&(u.start+="Sqrl.F."+e+"(",u.end+=")")}()}function a(e){return f=!!e}var f=!0;function c(e,n){var t,r,i="",o="";if(n&&""!==n){t=n.split("|");for(var l=0;l<t.length;l++)t[l]=t[l].trim(),""!==t[l]&&("safe"!==t[l]?(i="Sqrl.F."+t[l]+"("+i,o+=")"):r=!0)}return i+=u.start,o+=u.end,!r&&f&&(i+="Sqrl.F.e(",o+=")"),i+e+o}var s=/{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)) *?}}/g,d={s:"{{",e:"}}"},v=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[\\]@(?:[\w$]*:)?[\w$]+|@(?:([\w$]*):)?([\w$]+)/g,p=s,h=d;function g(e){x(e[0],e[1]),s=p,d=h}function x(e,n){var t=e+p.source.slice(h.s.length,0-h.e.length)+n,r=p.lastIndex;h={s:e,e:n},(p=RegExp(t,"g")).lastIndex=r}function y(e){return e=e.replace(v,function(e,n,t){return void 0===t?e:(void 0===n&&(n=""),"hvals"+n+"."+t)})}var R={if:{helperStart:function(e){return"if("+e+"){"},helperEnd:function(){return"}"},blocks:{else:function(){return"}else{"}}},each:{helperStart:function(e,n){return"for(var i=0;i<"+e+".length; i++){tR+=(function(hvals){var tR='';var hvals"+n+"=hvals;"},helperEnd:function(e){return"return tR})({this:"+e+"[i],index:i})};"}},foreach:{helperStart:function(e,n){return"for(var key in "+e+"){if(!"+e+".hasOwnProperty(key)) continue;tR+=(function(hvals){var tR='';var hvals"+n+"=hvals;"},helperEnd:function(e){return"return tR})({this:"+e+"[key], key: key})};"}},log:{selfClosing:function(e){return"console.log("+e+");"}},tags:{selfClosing:function(e){return x(e.slice(0,e.indexOf(",")).trim(),e.slice(e.indexOf(",")+1).trim()),""}},js:{selfClosing:function(e){return e+";"}}},m={};var b=function(e){var n,t=0,r="",i=[],o=-1,u=0,l={};for(h=d,(p=s).lastIndex=0;null!==(n=p.exec(e));){if(""===r?r+="var tR='"+e.slice(t,n.index).replace(/'/g,"\\'")+"';":t!==n.index&&(r+="tR+='"+e.slice(t,n.index).replace(/'/g,"\\'")+"';"),t=n[0].length+n.index,n[1])r+="tR+="+F(n[1],n[4])+";";else if(n[3])r+="tR+="+$(n[3],n[2],n[4])+";";else if(n[5]){var a=n[7];""!==a&&null!==a||(a=u,u++);var f=R.hasOwnProperty(n[5]);o+=1;var v=n[6]||"";v=y(v),f||(v="["+v+"]");var g={name:n[5],id:a,params:v,native:f};i[o]=g,f?(r+=R[n[5]].helperStart(v,a),t=p.lastIndex):r+="tR+=Sqrl.H."+n[5]+"("+v+",function(hvals){var hvals"+a+"=hvals;var tR='';"}else if(n[8]){var x=i[o];x&&x.name===n[8]?(o-=1,!0===x.native?r+=R[x.name].helperEnd(x.params,x.id):l[x.id]?r+="return tR}});":r+="return tR});"):console.error("Helper beginning & end don't match.")}else if(n[9]){var b=i[o];if(b.native){var w=R[b.name];w.blocks&&w.blocks[n[9]]?(r+=w.blocks[n[9]](b.id),t=p.lastIndex):console.warn("Native helper '%s' doesn't accept that block.",b.name)}else l[b.id]?r+="return tR},"+n[9]+":function(hvals){var hvals"+b.id+"=hvals;var tR='';":(r+="return tR},{"+n[9]+":function(hvals){var hvals"+b.id+"=hvals;var tR='';",l[b.id]=!0)}else if(n[10]){var S=n[11]||"";if(S=y(S),"include"===n[10]){var O=e.slice(0,n.index),_=e.slice(n.index+n[0].length),P=S.replace(/'|"/g,"");e=O+m[P]+_,t=p.lastIndex=n.index}else R.hasOwnProperty(n[10])&&R[n[10]].hasOwnProperty("selfClosing")?(r+=R[n[10]].selfClosing(S),t=p.lastIndex):r+="tR+=Sqrl.H."+n[10]+"("+S+");"}else console.error("Err 0");function F(e,n){return c("options."+e,n)}function $(e,n,t){return c(void 0!==n?"hvals"+(/(?:\.\.\/)+/g.test(n)?i[o-n.length/3-1].id:n.slice(0,-1))+"."+e:"hvals."+e,t)}}return""===r?r+="var tR='"+e.slice(t,e.length).replace(/'/g,"\\'")+"';":t!==e.length&&(r+="tR+='"+e.slice(t,e.length).replace(/'/g,"\\'")+"';"),r+="return tR",new Function("options","Sqrl",r.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))},w={};function S(e,n){i[e]=n}function O(e,n){w[e]=n}function _(e,n){R[e]=n}function P(e,n){return"function"==typeof e?e(n,r):"string"==typeof e?b(e)(n,r):void 0}function F(e,n){m[e]=n}var $=function(e,n,t){fs.readFile(e,function(e,r){if(e)return t(e);var i=r.toString(),o=P(b(i),n);return t(null,o)})};t.d(n,"__express",function(){return $}),t.d(n,"H",function(){return w}),t.d(n,"Compile",function(){return b}),t.d(n,"defineFilter",function(){return S}),t.d(n,"defineHelper",function(){return O}),t.d(n,"defineNativeHelper",function(){return _}),t.d(n,"definePartial",function(){return F}),t.d(n,"Render",function(){return P}),t.d(n,"F",function(){return i}),t.d(n,"setDefaultFilters",function(){return l}),t.d(n,"autoEscaping",function(){return a}),t.d(n,"defaultTags",function(){return g})}])}); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Sqrl=n():e.Sqrl=n()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var r={};t.r(r),t.d(r,"__express",function(){return $}),t.d(r,"H",function(){return w}),t.d(r,"Compile",function(){return b}),t.d(r,"defineFilter",function(){return S}),t.d(r,"defineHelper",function(){return O}),t.d(r,"defineNativeHelper",function(){return _}),t.d(r,"definePartial",function(){return F}),t.d(r,"Render",function(){return P}),t.d(r,"F",function(){return i}),t.d(r,"setDefaultFilters",function(){return l}),t.d(r,"autoEscaping",function(){return a}),t.d(r,"defaultTags",function(){return g});var i={e:function(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};var t=String(e);return/[&<>"'/]/.test(t)?t.replace(/[&<>"'/]/g,function(e){return n[e]}):t}},u={},o={start:"",end:""};function l(e){if("clear"===e)u={};else for(var n in e)e.hasOwnProperty(n)&&(u[n]=e[n]);!function(){for(var e in o={start:"",end:""},u)u.hasOwnProperty(e)&&u[e]&&(o.start+="Sqrl.F."+e+"(",o.end+=")")}()}function a(e){return f=!!e}var f=!0;function c(e,n){var t,r,i="",u="";if(n&&""!==n){t=n.split("|");for(var l=0;l<t.length;l++)t[l]=t[l].trim(),""!==t[l]&&("safe"!==t[l]?(i="Sqrl.F."+t[l]+"("+i,u+=")"):r=!0)}return i+=o.start,u+=o.end,!r&&f&&(i+="Sqrl.F.e(",u+=")"),i+e+u}var s=/{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)|(?:!--[^]+?--)) *?}}/g,d={s:"{{",e:"}}"},v=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[\\]@(?:[\w$]*:)?[\w$]+|@(?:([\w$]*):)?([\w$]+)/g,p=s,h=d;function g(e){x(e[0],e[1]),s=p,d=h}function x(e,n){var t=e+p.source.slice(h.s.length,0-h.e.length)+n,r=p.lastIndex;h={s:e,e:n},(p=RegExp(t,"g")).lastIndex=r}function y(e){return e=e.replace(v,function(e,n,t){return void 0===t?e:(void 0===n&&(n=""),"hvals"+n+"."+t)})}var R={if:{helperStart:function(e){return"if("+e+"){"},helperEnd:function(){return"}"},blocks:{else:function(){return"}else{"}}},each:{helperStart:function(e,n){return"for(var i=0;i<"+e+".length; i++){tR+=(function(hvals){var tR='';var hvals"+n+"=hvals;"},helperEnd:function(e){return"return tR})({this:"+e+"[i],index:i})};"}},foreach:{helperStart:function(e,n){return"for(var key in "+e+"){if(!"+e+".hasOwnProperty(key)) continue;tR+=(function(hvals){var tR='';var hvals"+n+"=hvals;"},helperEnd:function(e){return"return tR})({this:"+e+"[key], key: key})};"}},log:{selfClosing:function(e){return"console.log("+e+");"}},tags:{selfClosing:function(e){return x(e.slice(0,e.indexOf(",")).trim(),e.slice(e.indexOf(",")+1).trim()),""}},js:{selfClosing:function(e){return e+";"}}},m={};var b=function(e){var n,t=0,r="",i=[],u=-1,o=0,l={};for(h=d,(p=s).lastIndex=0;null!==(n=p.exec(e));){if(""===r?r+="var tR='"+e.slice(t,n.index).replace(/'/g,"\\'")+"';":t!==n.index&&(r+="tR+='"+e.slice(t,n.index).replace(/'/g,"\\'")+"';"),t=n[0].length+n.index,n[1])r+="tR+="+F(n[1],n[4])+";";else if(n[3])r+="tR+="+$(n[3],n[2],n[4])+";";else if(n[5]){var a=n[7];""!==a&&null!==a||(a=o,o++);var f=R.hasOwnProperty(n[5]);u+=1;var v=n[6]||"";v=y(v),f||(v="["+v+"]");var g={name:n[5],id:a,params:v,native:f};i[u]=g,f?(r+=R[n[5]].helperStart(v,a),t=p.lastIndex):r+="tR+=Sqrl.H."+n[5]+"("+v+",function(hvals){var hvals"+a+"=hvals;var tR='';"}else if(n[8]){var x=i[u];x&&x.name===n[8]?(u-=1,!0===x.native?r+=R[x.name].helperEnd(x.params,x.id):l[x.id]?r+="return tR}});":r+="return tR});"):console.error("Helper beginning & end don't match.")}else if(n[9]){var b=i[u];if(b.native){var w=R[b.name];w.blocks&&w.blocks[n[9]]?(r+=w.blocks[n[9]](b.id),t=p.lastIndex):console.warn("Native helper '%s' doesn't accept that block.",b.name)}else l[b.id]?r+="return tR},"+n[9]+":function(hvals){var hvals"+b.id+"=hvals;var tR='';":(r+="return tR},{"+n[9]+":function(hvals){var hvals"+b.id+"=hvals;var tR='';",l[b.id]=!0)}else if(n[10]){var S=n[11]||"";if(S=y(S),"include"===n[10]){var O=e.slice(0,n.index),_=e.slice(n.index+n[0].length),P=S.replace(/'|"/g,"");e=O+m[P]+_,t=p.lastIndex=n.index}else R.hasOwnProperty(n[10])&&R[n[10]].hasOwnProperty("selfClosing")?(r+=R[n[10]].selfClosing(S),t=p.lastIndex):r+="tR+=Sqrl.H."+n[10]+"("+S+");"}function F(e,n){return c("options."+e,n)}function $(e,n,t){return c(void 0!==n?"hvals"+(/(?:\.\.\/)+/g.test(n)?i[u-n.length/3-1].id:n.slice(0,-1))+"."+e:"hvals."+e,t)}}return""===r?r+="var tR='"+e.slice(t,e.length).replace(/'/g,"\\'")+"';":t!==e.length&&(r+="tR+='"+e.slice(t,e.length).replace(/'/g,"\\'")+"';"),r+="return tR",new Function("options","Sqrl",r.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))},w={};function S(e,n){i[e]=n}function O(e,n){w[e]=n}function _(e,n){R[e]=n}function P(e,n){return"function"==typeof e?e(n,r):"string"==typeof e?b(e)(n,r):void 0}function F(e,n){m[e]=n}var $=function(e,n,t){fs.readFile(e,function(e,r){if(e)return t(e);var i=r.toString(),u=P(b(i),n);return t(null,u)})};t.d(n,"__express",function(){return $}),t.d(n,"H",function(){return w}),t.d(n,"Compile",function(){return b}),t.d(n,"defineFilter",function(){return S}),t.d(n,"defineHelper",function(){return O}),t.d(n,"defineNativeHelper",function(){return _}),t.d(n,"definePartial",function(){return F}),t.d(n,"Render",function(){return P}),t.d(n,"F",function(){return i}),t.d(n,"setDefaultFilters",function(){return l}),t.d(n,"autoEscaping",function(){return a}),t.d(n,"defaultTags",function(){return g})}])}); | ||
//# sourceMappingURL=squirrelly.min.js.map |
@@ -121,6 +121,6 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var funcStr = '' | ||
var helperArray = [] | ||
var helperArray = [] // A list of all 'outstanding' helpers, or unclosed helpers | ||
var helperNumber = -1 | ||
var helperAutoId = 0 | ||
var helperContainsBlocks = {} | ||
var helperAutoId = 0 // Squirrelly automatically generates an ID for helpers that don't have a custom ID | ||
var helperContainsBlocks = {} // If a helper contains any blocks, helperContainsBlocks[helperID] will be set to true | ||
var m | ||
@@ -192,3 +192,3 @@ Object(_regexps__WEBPACK_IMPORTED_MODULE_0__["setup"])() | ||
funcStr += nativeH.blocks[m[9]](parent.id) | ||
lastIndex = _regexps__WEBPACK_IMPORTED_MODULE_0__["regEx"].lastIndex | ||
lastIndex = _regexps__WEBPACK_IMPORTED_MODULE_0__["regEx"].lastIndex // Some native helpers set regEx.lastIndex | ||
} else { | ||
@@ -210,5 +210,7 @@ console.warn("Native helper '%s' doesn't accept that block.", parent.name) | ||
if (m[10] === 'include') { | ||
// This code literally gets the template string up to the include self-closing helper, | ||
// adds the content of the partial, and adds the template string after the include self-closing helper | ||
var preContent = str.slice(0, m.index) | ||
var endContent = str.slice(m.index + m[0].length) | ||
var partialParams = innerParams.replace(/'|"/g, '') | ||
var partialParams = innerParams.replace(/'|"/g, '') // So people can write {{include(mypartial)/}} or {{include('mypartial')/}} | ||
var partialContent = _partials__WEBPACK_IMPORTED_MODULE_3__["default"][partialParams] | ||
@@ -221,6 +223,4 @@ str = preContent + partialContent + endContent | ||
} else { | ||
funcStr += 'tR+=Sqrl.H.' + m[10] + '(' + innerParams + ');' | ||
funcStr += 'tR+=Sqrl.H.' + m[10] + '(' + innerParams + ');' // If it's not native, passing args to a non-native helper | ||
} | ||
} else { | ||
console.error('Err 0') | ||
} | ||
@@ -235,3 +235,3 @@ /* eslint-disable no-inner-declarations */ | ||
if (typeof id !== 'undefined') { | ||
if (/(?:\.\.\/)+/g.test(id)) { | ||
if (/(?:\.\.\/)+/g.test(id)) { // Test if the helper reference is prefixed with ../ | ||
prefix = helperArray[helperNumber - (id.length / 3) - 1].id | ||
@@ -347,2 +347,3 @@ } else { | ||
var defaultFilterCache = { | ||
// This is to prevent having to re-calculate default filters every time you return a filtered string | ||
start: '', | ||
@@ -398,2 +399,4 @@ end: '' | ||
if (filtersArray[i] === 'safe') { | ||
// If 'safe' is one of the filters, set safe to true but don't add Sqrl.F.safe | ||
// Essentially, 'safe' is a flag telling Squirrelly not to autoEscape | ||
safe = true | ||
@@ -434,3 +437,5 @@ continue | ||
__webpack_require__.r(__webpack_exports__); | ||
var helpers = { // For helpers. None included to make it more lightweight | ||
var helpers = { | ||
// No helpers are included by default for the sake of size, | ||
// But there's an example of a helper below | ||
/* | ||
@@ -562,3 +567,3 @@ Date: function (args, content, blocks, options) { | ||
}, | ||
js: { | ||
js: { // The js self-closing helper allows you to inject JavaScript straight into your template function | ||
selfClosing: function (param) { | ||
@@ -613,3 +618,3 @@ return param + ';' | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "replaceParamHelpers", function() { return replaceParamHelpers; }); | ||
var initialRegEx = /{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)) *?}}/g | ||
var initialRegEx = /{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)|(?:!--[^]+?--)) *?}}/g | ||
var initialTags = { | ||
@@ -669,3 +674,3 @@ s: '{{', | ||
(?: //choosing global or helper ref | ||
(?:([a-zA-Z_$][\w]* *?(?:[^\s\w\($][^\n]*)*?)) //global reference | ||
(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?)) //global reference | ||
| | ||
@@ -684,2 +689,4 @@ (?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *) //helper reference | ||
(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/) | ||
| //now for comments | ||
(?:!--[^]+?--) | ||
) //end or for each possible tag | ||
@@ -729,2 +736,3 @@ *?}} | ||
// So we can pass Sqrl as a parameter to Render() | ||
@@ -734,3 +742,2 @@ | ||
function defineFilter (name, callback) { | ||
@@ -749,2 +756,4 @@ _filters__WEBPACK_IMPORTED_MODULE_0__["default"][name] = callback | ||
function Render (template, options) { | ||
// If the template parameter is a function, call that function with (options, Sqrl) | ||
// If it's a string, first compile the string and then call the function | ||
if (typeof template === 'function') { | ||
@@ -751,0 +760,0 @@ return template(options, _index__WEBPACK_IMPORTED_MODULE_2__) |
@@ -1,2 +0,2 @@ | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Sqrl=e():n.Sqrl=e()}("undefined"!=typeof self?self:this,function(){return function(n){var e={};function t(r){if(e[r])return e[r].exports;var u=e[r]={i:r,l:!1,exports:{}};return n[r].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var u in n)t.d(r,u,function(e){return n[e]}.bind(null,u));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r={};t.r(r),t.d(r,"__express",function(){return F}),t.d(r,"H",function(){return x}),t.d(r,"Compile",function(){return b}),t.d(r,"defineFilter",function(){return _}),t.d(r,"defineHelper",function(){return m}),t.d(r,"defineNativeHelper",function(){return w}),t.d(r,"definePartial",function(){return S}),t.d(r,"Render",function(){return j}),t.d(r,"F",function(){return u}),t.d(r,"setDefaultFilters",function(){return f}),t.d(r,"autoEscaping",function(){return c}),t.d(r,"defaultTags",function(){return p});var u={e:function(n){var e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};var t=String(n);return/[&<>"'/]/.test(t)?t.replace(/[&<>"'/]/g,function(n){return e[n]}):t}},o={},i={start:"",end:""};function f(n){if("clear"===n)o={};else for(var e in n)n.hasOwnProperty(e)&&(o[e]=n[e]);!function(){for(var n in i={start:"",end:""},o)o.hasOwnProperty(n)&&o[n]&&(i.start+="Sqrl.F."+n+"(",i.end+=")")}()}function c(n){return!!n}var d=/{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)) *?}}/g,a={s:"{{",e:"}}"},l=d,s=a;function p(n){v(n[0],n[1]),d=l,a=s}function v(n,e){var t=n+l.source.slice(s.s.length,0-s.e.length)+e,r=l.lastIndex;s={s:n,e:e},(l=RegExp(t,"g")).lastIndex=r}var y={},g={};var b={},x={};function _(n,e){u[n]=e}function m(n,e){x[n]=e}function w(n,e){y[n]=e}function j(n,e){return"function"==typeof n?n(e,r):"string"==typeof n?b(n)(e,r):void 0}function S(n,e){g[n]=e}var F=function(n,e,t){fs.readFile(n,function(n,r){if(n)return t(n);var u=r.toString(),o=j(b(u),e);return t(null,o)})};t.d(e,"__express",function(){return F}),t.d(e,"H",function(){return x}),t.d(e,"Compile",function(){return b}),t.d(e,"defineFilter",function(){return _}),t.d(e,"defineHelper",function(){return m}),t.d(e,"defineNativeHelper",function(){return w}),t.d(e,"definePartial",function(){return S}),t.d(e,"Render",function(){return j}),t.d(e,"F",function(){return u}),t.d(e,"setDefaultFilters",function(){return f}),t.d(e,"autoEscaping",function(){return c}),t.d(e,"defaultTags",function(){return p})}])}); | ||
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Sqrl=e():n.Sqrl=e()}("undefined"!=typeof self?self:this,function(){return function(n){var e={};function t(r){if(e[r])return e[r].exports;var u=e[r]={i:r,l:!1,exports:{}};return n[r].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var u in n)t.d(r,u,function(e){return n[e]}.bind(null,u));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r={};t.r(r),t.d(r,"__express",function(){return F}),t.d(r,"H",function(){return x}),t.d(r,"Compile",function(){return b}),t.d(r,"defineFilter",function(){return _}),t.d(r,"defineHelper",function(){return m}),t.d(r,"defineNativeHelper",function(){return w}),t.d(r,"definePartial",function(){return S}),t.d(r,"Render",function(){return j}),t.d(r,"F",function(){return u}),t.d(r,"setDefaultFilters",function(){return f}),t.d(r,"autoEscaping",function(){return c}),t.d(r,"defaultTags",function(){return p});var u={e:function(n){var e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};var t=String(n);return/[&<>"'/]/.test(t)?t.replace(/[&<>"'/]/g,function(n){return e[n]}):t}},o={},i={start:"",end:""};function f(n){if("clear"===n)o={};else for(var e in n)n.hasOwnProperty(e)&&(o[e]=n[e]);!function(){for(var n in i={start:"",end:""},o)o.hasOwnProperty(n)&&o[n]&&(i.start+="Sqrl.F."+n+"(",i.end+=")")}()}function c(n){return!!n}var d=/{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)|(?:!--[^]+?--)) *?}}/g,a={s:"{{",e:"}}"},l=d,s=a;function p(n){v(n[0],n[1]),d=l,a=s}function v(n,e){var t=n+l.source.slice(s.s.length,0-s.e.length)+e,r=l.lastIndex;s={s:n,e:e},(l=RegExp(t,"g")).lastIndex=r}var y={},g={};var b={},x={};function _(n,e){u[n]=e}function m(n,e){x[n]=e}function w(n,e){y[n]=e}function j(n,e){return"function"==typeof n?n(e,r):"string"==typeof n?b(n)(e,r):void 0}function S(n,e){g[n]=e}var F=function(n,e,t){fs.readFile(n,function(n,r){if(n)return t(n);var u=r.toString(),o=j(b(u),e);return t(null,o)})};t.d(e,"__express",function(){return F}),t.d(e,"H",function(){return x}),t.d(e,"Compile",function(){return b}),t.d(e,"defineFilter",function(){return _}),t.d(e,"defineHelper",function(){return m}),t.d(e,"defineNativeHelper",function(){return w}),t.d(e,"definePartial",function(){return S}),t.d(e,"Render",function(){return j}),t.d(e,"F",function(){return u}),t.d(e,"setDefaultFilters",function(){return f}),t.d(e,"autoEscaping",function(){return c}),t.d(e,"defaultTags",function(){return p})}])}); | ||
//# sourceMappingURL=squirrelly.runtime.js.map |
{ | ||
"name": "squirrelly", | ||
"version": "5.0.1", | ||
"version": "5.1.0", | ||
"description": "A simple yet powerful modern template engine that works in the browser, in Node.js, and with ExpressJS.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/squirrelly.min.js", |
@@ -7,3 +7,3 @@ | ||
Squirrelly is a modern, configurable, and blazing fast template engine implemented in JavaScript. It works out of the box with ExpressJS and has a small footprint. | ||
Squirrelly is a modern, configurable, and blazing fast template engine implemented in JavaScript. It works out of the box with ExpressJS and weighs only **2.5KB gzipped**. | ||
@@ -51,2 +51,2 @@ ## Why Squirrelly? | ||
Squirrelly is licensed under the MIT license. | ||
Squirrelly is licensed under the MIT license. |
@@ -16,6 +16,6 @@ /* global RUNTIME */ | ||
var funcStr = '' | ||
var helperArray = [] | ||
var helperArray = [] // A list of all 'outstanding' helpers, or unclosed helpers | ||
var helperNumber = -1 | ||
var helperAutoId = 0 | ||
var helperContainsBlocks = {} | ||
var helperAutoId = 0 // Squirrelly automatically generates an ID for helpers that don't have a custom ID | ||
var helperContainsBlocks = {} // If a helper contains any blocks, helperContainsBlocks[helperID] will be set to true | ||
var m | ||
@@ -87,3 +87,3 @@ setup() | ||
funcStr += nativeH.blocks[m[9]](parent.id) | ||
lastIndex = regEx.lastIndex | ||
lastIndex = regEx.lastIndex // Some native helpers set regEx.lastIndex | ||
} else { | ||
@@ -105,5 +105,7 @@ console.warn("Native helper '%s' doesn't accept that block.", parent.name) | ||
if (m[10] === 'include') { | ||
// This code literally gets the template string up to the include self-closing helper, | ||
// adds the content of the partial, and adds the template string after the include self-closing helper | ||
var preContent = str.slice(0, m.index) | ||
var endContent = str.slice(m.index + m[0].length) | ||
var partialParams = innerParams.replace(/'|"/g, '') | ||
var partialParams = innerParams.replace(/'|"/g, '') // So people can write {{include(mypartial)/}} or {{include('mypartial')/}} | ||
var partialContent = P[partialParams] | ||
@@ -116,6 +118,4 @@ str = preContent + partialContent + endContent | ||
} else { | ||
funcStr += 'tR+=Sqrl.H.' + m[10] + '(' + innerParams + ');' | ||
funcStr += 'tR+=Sqrl.H.' + m[10] + '(' + innerParams + ');' // If it's not native, passing args to a non-native helper | ||
} | ||
} else { | ||
console.error('Err 0') | ||
} | ||
@@ -130,3 +130,3 @@ /* eslint-disable no-inner-declarations */ | ||
if (typeof id !== 'undefined') { | ||
if (/(?:\.\.\/)+/g.test(id)) { | ||
if (/(?:\.\.\/)+/g.test(id)) { // Test if the helper reference is prefixed with ../ | ||
prefix = helperArray[helperNumber - (id.length / 3) - 1].id | ||
@@ -133,0 +133,0 @@ } else { |
@@ -34,2 +34,3 @@ export var filters = { | ||
export var defaultFilterCache = { | ||
// This is to prevent having to re-calculate default filters every time you return a filtered string | ||
start: '', | ||
@@ -85,2 +86,4 @@ end: '' | ||
if (filtersArray[i] === 'safe') { | ||
// If 'safe' is one of the filters, set safe to true but don't add Sqrl.F.safe | ||
// Essentially, 'safe' is a flag telling Squirrelly not to autoEscape | ||
safe = true | ||
@@ -87,0 +90,0 @@ continue |
@@ -1,2 +0,4 @@ | ||
var helpers = { // For helpers. None included to make it more lightweight | ||
var helpers = { | ||
// No helpers are included by default for the sake of size, | ||
// But there's an example of a helper below | ||
/* | ||
@@ -3,0 +5,0 @@ Date: function (args, content, blocks, options) { |
@@ -46,3 +46,3 @@ /* global RUNTIME */ | ||
}, | ||
js: { | ||
js: { // The js self-closing helper allows you to inject JavaScript straight into your template function | ||
selfClosing: function (param) { | ||
@@ -49,0 +49,0 @@ return param + ';' |
@@ -1,2 +0,2 @@ | ||
export var initialRegEx = /{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)) *?}}/g | ||
export var initialRegEx = /{{ *?(?:(?:(?:(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?))|(?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *))(?: *?(\| *?[\w$]+? *?)+?)?)|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?([\w]*))|(?:\/ *?([a-zA-Z_$][\w]*))|(?:# *?([a-zA-Z_$][\w]*))|(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/)|(?:!--[^]+?--)) *?}}/g | ||
export var initialTags = { | ||
@@ -56,3 +56,3 @@ s: '{{', | ||
(?: //choosing global or helper ref | ||
(?:([a-zA-Z_$][\w]* *?(?:[^\s\w\($][^\n]*)*?)) //global reference | ||
(?:([a-zA-Z_$][\w]* *?(?:[^\s\w($][^\n]*)*?)) //global reference | ||
| | ||
@@ -71,2 +71,4 @@ (?:@(?:([\w$]+:|(?:\.\.\/)+))? *(.+?) *) //helper reference | ||
(?:([a-zA-Z_$][\w]*) *?\(([^\n]*)\) *?\/) | ||
| //now for comments | ||
(?:!--[^]+?--) | ||
) //end or for each possible tag | ||
@@ -73,0 +75,0 @@ *?}} |
import F from './filters' | ||
import C from './compile' | ||
import * as Sqrl from './index' | ||
import * as Sqrl from './index' // So we can pass Sqrl as a parameter to Render() | ||
import H from './helpers' | ||
@@ -21,2 +21,4 @@ import n from './nativeHelpers' | ||
export function Render (template, options) { | ||
// If the template parameter is a function, call that function with (options, Sqrl) | ||
// If it's a string, first compile the string and then call the function | ||
if (typeof template === 'function') { | ||
@@ -23,0 +25,0 @@ return template(options, Sqrl) |
/* eslint-env mocha */ | ||
var assert = require('assert') | ||
var Sqrl = require('../dist/squirrelly.min.js') | ||
// This is a mocha test file containing a couple of tests to make sure Squirrelly isn't broken. | ||
// The code at the bottom tests that when you render simpleTemplate with options, it equals simpleTemplateResult. | ||
// It also tests that bigTemplate, rendered, equals bigTemplateResult. | ||
@@ -96,2 +99,3 @@ var simpleTemplate = ` | ||
}) | ||
}) | ||
}) |
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
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
206749
31
1963
51