snakeskin
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -37,2 +37,3 @@ #!/usr/bin/env node | ||
.option('--tolerate-whitespace', 'tolerate whitespace characters in the template') | ||
.option('--ignore', 'regular expression to ignore the empty space') | ||
@@ -91,2 +92,5 @@ .option('--auto-replace', 'enable macros support') | ||
params.tolerateWhitespace = 'tolerateWhitespace' in program ? | ||
program['tolerateWhitespace'] : params.tolerateWhitespace; | ||
params.ignore = 'ignore' in program ? | ||
@@ -292,3 +296,3 @@ program['ignore'] : params.ignore; | ||
} else { | ||
res = beautify[path.extname(outFile).replace(/^\./, '')](res); | ||
res = (beautify[path.extname(outFile).replace(/^\./, '')] || beautify['html'])(res); | ||
} | ||
@@ -295,0 +299,0 @@ } |
{ | ||
"name": "Snakeskin", | ||
"main": "build/snakeskin.min.js", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"homepage": "https://github.com/kobezzza/Snakeskin", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
/*! | ||
* Snakeskin v5.0.0 (live) | ||
* Snakeskin v5.1.0 (live) | ||
* https://github.com/kobezzza/Snakeskin | ||
@@ -8,3 +8,3 @@ * | ||
* | ||
* Date: Tue, 30 Sep 2014 10:58:02 GMT | ||
* Date: Thu, 02 Oct 2014 09:46:36 GMT | ||
*/ | ||
@@ -37,3 +37,3 @@ | ||
*/ | ||
VERSION: [5, 0, 0], | ||
VERSION: [5, 1, 0], | ||
@@ -40,0 +40,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
/*! Snakeskin v5.0.0 (live) | https://github.com/kobezzza/Snakeskin/blob/master/LICENSE */Array.isArray=Array.isArray||function(k){return"[object Array]"==={}.toString.call(k)};String.prototype.trim=String.prototype.trim||function(){for(var k=this.replace(/^\s\s*/,""),l=k.length,m=/\s/;m.test(k.charAt(--l)););return k.substring(0,l+1)};var e={VERSION:[5,0,0],a:{},Filters:{},Vars:{},LocalVars:{},cache:{}}; | ||
/*! Snakeskin v5.1.0 (live) | https://github.com/kobezzza/Snakeskin/blob/master/LICENSE */Array.isArray=Array.isArray||function(k){return"[object Array]"==={}.toString.call(k)};String.prototype.trim=String.prototype.trim||function(){for(var k=this.replace(/^\s\s*/,""),l=k.length,m=/\s/;m.test(k.charAt(--l)););return k.substring(0,l+1)};var e={VERSION:[5,1,0],a:{},Filters:{},Vars:{},LocalVars:{},cache:{}}; | ||
(function(){function k(a){return m[a]}var l="undefined"===typeof window&&"undefined"!==typeof exports;e.importFilters=function(a,f){var c=e.Filters;if(f)for(var d=f.split("."),g=-1;++g<d.length;)c[d[g]]||(c[d[g]]={}),c=c[d[g]];for(var h in a)a.hasOwnProperty(h)&&(c[h]=a[h])};var m={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},p=/[&<>"'\/]/g,q=/([$\w]\s*=\s*)([^"'\s>=]+)/g,r=/(javascript)(:|;)/;e.Filters.html=function(a,f){var c=a+"";f&&(c=c.replace(q,'$1"$2"'));c=c.replace(p, | ||
@@ -3,0 +3,0 @@ k);f&&(c=c.replace(r,"$1$2"));return c};e.Filters.undef=function(a){return void 0!==a?a:""};(function(){function a(b){return f[b]}var f={"&":"&","<":"<",">":">",""":'"',"'":"'","/":"/"},c=/&|<|>|"|'|//g;e.Filters.uhtml=function(b){return(b+"").replace(c,a)};var d=/<\/?[^>]+>/g;e.Filters.stripTags=function(b){return(b+"").replace(d,"")};var g=/%5B/g,h=/%5D/g;e.Filters.uri=function(b){return encodeURI(b+"").replace(g,"[").replace(h,"]")};e.Filters.upper= |
@@ -1,2 +0,2 @@ | ||
/* Snakeskin v5.0.0, key <true,true,false,,stringConcat,true,true,,false,true,i18n>, label <1412074961864>, includes <>, generated at <1412075010098>. | ||
/* Snakeskin v5.1.0, key <true,true,false,false,,stringConcat,true,true,,false,true,i18n>, label <1412075167844>, includes <>, generated at <1412239433963>. | ||
This code is generated automatically, don't alter it. */ | ||
@@ -24,3 +24,3 @@ (function() { | ||
__STR__, __TMP__, __J__; | ||
var $_ = __LOCAL__['$_5bca9']; /* Snakeskin template: helloWorld; name */ | ||
var $_ = __LOCAL__['$_e1045']; /* Snakeskin template: helloWorld; name */ | ||
this.helloWorld = function(name) { | ||
@@ -46,8 +46,8 @@ var __THIS__ = this, | ||
function clearTplResult() { | ||
__RESULT__ = ''; | ||
} | ||
__RESULT__ = ''; | ||
} | ||
var __RETURN__ = false, | ||
__RETURN_VAL__; | ||
var TPL_NAME = 'helloWorld', | ||
PARENT_TPL_NAME; | ||
__RETURN_VAL__; | ||
var TPL_NAME = "helloWorld", | ||
PARENT_TPL_NAME; | ||
name = arguments[0] = name != null ? name : 'world'; | ||
@@ -57,6 +57,6 @@ __RESULT__ += '<h1>Hello '; | ||
__RESULT__ += '!</h1> '; | ||
return __RESULT__; | ||
}; | ||
Snakeskin.cache['helloWorld'] = this.helloWorld; /* Snakeskin template. */ | ||
return __RESULT__; | ||
}; | ||
Snakeskin.cache["helloWorld"] = this.helloWorld; /* Snakeskin template. */ | ||
} | ||
}).call(this); | ||
}).call(this); |
@@ -1,2 +0,2 @@ | ||
/* Snakeskin v5.0.0, key <false,true,false,,stringConcat,true,true,,false,true,i18n>, label <1412074961864>, includes <>, generated at <1412074993298>. | ||
/* Snakeskin v5.1.0, key <false,true,false,false,,stringConcat,true,true,,false,true,i18n>, label <1412075167844>, includes <>, generated at <1412239404190>. | ||
This code is generated automatically, don't alter it. */ | ||
@@ -15,3 +15,3 @@ (function() { | ||
__STR__, __TMP__, __J__; | ||
var $_ = __LOCAL__['$_0356c']; /* Snakeskin template: helloWorld; name */ | ||
var $_ = __LOCAL__['$_49d6c']; /* Snakeskin template: helloWorld; name */ | ||
this.helloWorld = function helloWorld(name) { | ||
@@ -37,8 +37,8 @@ var __THIS__ = this, | ||
function clearTplResult() { | ||
__RESULT__ = ''; | ||
} | ||
__RESULT__ = ''; | ||
} | ||
var __RETURN__ = false, | ||
__RETURN_VAL__; | ||
var TPL_NAME = 'helloWorld', | ||
PARENT_TPL_NAME; | ||
__RETURN_VAL__; | ||
var TPL_NAME = "helloWorld", | ||
PARENT_TPL_NAME; | ||
name = arguments[0] = name != null ? name : 'world'; | ||
@@ -48,5 +48,5 @@ __RESULT__ += '<h1>Hello '; | ||
__RESULT__ += '!</h1> '; | ||
return __RESULT__; | ||
}; | ||
Snakeskin.cache['helloWorld'] = this.helloWorld; /* Snakeskin template. */ | ||
}).call(this); | ||
return __RESULT__; | ||
}; | ||
Snakeskin.cache["helloWorld"] = this.helloWorld; /* Snakeskin template. */ | ||
}).call(this); |
@@ -0,1 +1,7 @@ | ||
## v5.1.0 | ||
- [x] Добавлен новый флаг трансляции `tolerateWhitespace`; | ||
- [x] Добавлен псевдокласс `:inline` для директивы `tag`; | ||
- [x] Переработан механизм обработки пробельных символов. | ||
## v5.0.0 | ||
@@ -2,0 +8,0 @@ |
@@ -47,5 +47,5 @@ /*! | ||
this.strongSpace = false; | ||
this.space = true; | ||
this.space = !this.tolerateWhitespace; | ||
return this; | ||
}; |
@@ -36,2 +36,5 @@ Snakeskin.DirObj = DirObj; | ||
* | ||
* @param {boolean} params.tolerateWhitespace - если true, то пробельные символы | ||
* вставляются "как есть" | ||
* | ||
* @param {boolean} params.escapeOutput - если false, то на вывод значений через директиву output | ||
@@ -101,2 +104,8 @@ * не будет накладываться фильтр html | ||
*/ | ||
this.tolerateWhitespace = params.tolerateWhitespace; | ||
/** | ||
* @expose | ||
* @type {boolean} | ||
*/ | ||
this.inlineIterators = params.inlineIterators; | ||
@@ -183,3 +192,4 @@ | ||
language: this.language, | ||
ignore: this.ignore | ||
ignore: this.ignore, | ||
tolerateWhitespace: this.tolerateWhitespace | ||
} | ||
@@ -186,0 +196,0 @@ ]; |
@@ -93,8 +93,20 @@ /*! | ||
function applyDefEscape(str) { | ||
function escapeSingleQuote(str) { | ||
return String(str) | ||
.replace(/\\/gm, '\\\\') | ||
.replace(/'/gm, '\\\''); | ||
} | ||
function escapeDoubleQuote(str) { | ||
return String(str) | ||
.replace(/"/gm, '\\\"'); | ||
} | ||
function applyDefEscape(str) { | ||
return escapeNextLine( | ||
String(str) | ||
.replace(/\\/gm, '\\\\') | ||
.replace(/'/gm, '\\\'') | ||
); | ||
} | ||
function escapeNextLine(str) { | ||
@@ -101,0 +113,0 @@ return String(str) |
@@ -10,2 +10,3 @@ var uid; | ||
DirObj.prototype.evalStr = function (str) { | ||
str = this.pasteDangerBlocks(str); | ||
var module = this.module; | ||
@@ -12,0 +13,0 @@ var filename = module.filename, |
@@ -6,5 +6,10 @@ /*! | ||
(function() { | ||
var alb = ADV_LEFT_BLOCK, | ||
lb = LEFT_BLOCK, | ||
rb = RIGHT_BLOCK; | ||
var commandRgxp = /([^\s]+).*/, | ||
rightWSRgxp = /\s*$/, | ||
nonBlockCommentRgxp = /([^\\])\/\/\/(\s?)(.*)/, | ||
lastALBRgxp = new RegExp((("" + ADV_LEFT_BLOCK) + "$")); | ||
lastALBRgxp = new RegExp((("" + alb) + "$")); | ||
@@ -20,2 +25,3 @@ /** | ||
DirObj.prototype.toBaseSyntax = function (str, i) { | ||
var ws = !this.tolerateWhitespace; | ||
var clrL = true, | ||
@@ -31,6 +37,17 @@ spaces = 0, | ||
var alb = ADV_LEFT_BLOCK, | ||
lb = LEFT_BLOCK, | ||
rb = RIGHT_BLOCK; | ||
function f(struct, chains, obj) { | ||
if (struct.block) { | ||
if (chains[struct.name] && chains[struct.name][obj.name]) { | ||
obj.block = true; | ||
obj.name = struct.name; | ||
} else { | ||
var tmp = rightWSRgxp.exec(res)[0]; | ||
res = res.replace(rightWSRgxp, ''); | ||
res += genEndDir(struct, ws, struct.space) + | ||
(tmp ? (("" + (struct.adv)) + ("" + lb) + ("__sp__" + rb) + "") : '') + tmp; | ||
} | ||
} | ||
} | ||
for (var j = i - 1; ++j < str.length;) { | ||
@@ -53,3 +70,3 @@ length++; | ||
if (clrL) { | ||
res += (("" + alb) + ("" + lb) + ("__&__" + rb) + ("" + el) + ""); | ||
res += el; | ||
} | ||
@@ -145,27 +162,18 @@ | ||
if (!obj.adv && struct.adv) { | ||
obj.block = false; | ||
} | ||
} else if (struct.spaces === spaces || struct.spaces < spaces && !struct.block) { | ||
if (struct.block) { | ||
if (chains[struct.name] && chains[struct.name][obj.name]) { | ||
obj.block = true; | ||
obj.name = struct.name; | ||
obj.parent = struct.parent; | ||
} else { | ||
res += genEndDir(struct); | ||
} | ||
if (!obj.adv && struct.parent && struct.parent.adv) { | ||
obj.block = false; | ||
} | ||
obj.parent = struct.parent; | ||
f(struct, chains, obj); | ||
} else { | ||
while (struct.spaces >= spaces) { | ||
if (struct.block) { | ||
if (chains[struct.name] && chains[struct.name][obj.name]) { | ||
obj.block = true; | ||
obj.name = struct.name; | ||
} else { | ||
res += genEndDir(struct); | ||
} | ||
} | ||
f(struct, chains, obj); | ||
struct = struct | ||
@@ -206,6 +214,2 @@ .parent; | ||
if (obj.block) { | ||
res += (("" + s) + ("__&__" + e) + ""); | ||
} | ||
var tmp = decl.length - 1; | ||
@@ -237,3 +241,3 @@ tSpace = 0; | ||
if (struct.block) { | ||
res += genEndDir(struct); | ||
res += genEndDir(struct, ws, struct.space); | ||
} | ||
@@ -255,9 +259,12 @@ | ||
* @param {!Object} dir - объект-описание директивы | ||
* @param {boolean} ws - если true, то лишние пробельные символы вырезаются | ||
* @param {string} space - доступное свободное пространство | ||
* @return {string} | ||
*/ | ||
function genEndDir(dir) { | ||
var s = dir.adv + LEFT_BLOCK, | ||
e = RIGHT_BLOCK; | ||
function genEndDir(dir, ws, space) { | ||
space = ws ? '' : | ||
(space || '').substring(1); | ||
return (("" + s) + ("__&__" + e) + ("\n" + s) + ("__end__" + e) + ("" + s) + ("__cutLine__" + e) + ("" + s) + ("__&__" + e) + ""); | ||
var s = dir.adv + lb; | ||
return (("" + (ws ? (("" + s) + ("__&__" + rb) + "") : '')) + ("\n" + space) + ("" + s) + ("__end__" + rb) + ("" + s) + ("__cutLine__" + rb) + ""); | ||
} | ||
@@ -264,0 +271,0 @@ |
@@ -29,3 +29,3 @@ /*! | ||
return val; | ||
return (val); | ||
}; | ||
@@ -32,0 +32,0 @@ |
@@ -0,0 +0,0 @@ /*! |
@@ -56,2 +56,5 @@ var nextLineRgxp = /\r|\n/, | ||
* | ||
* @param {?boolean=} [opt_params.tolerateWhitespace=false] - если true, то пробельные символы | ||
* вставляются "как есть" | ||
* | ||
* @param {?boolean=} [opt_params.inlineIterators=false] - если true, то итераторы forEach и forIn | ||
@@ -119,2 +122,3 @@ * будут развёрнуты в циклы | ||
p.inlineIterators = s(p.inlineIterators, p['inlineIterators']) || false; | ||
p.tolerateWhitespace = s(p.tolerateWhitespace, p['tolerateWhitespace']) || false; | ||
p.escapeOutput = s(p.escapeOutput, p['escapeOutput']) !== false; | ||
@@ -177,4 +181,5 @@ | ||
cjs, | ||
ctx !== NULL, | ||
p.xml, | ||
p.tolerateWhitespace, | ||
p.inlineIterators, | ||
@@ -187,3 +192,2 @@ p.renderAs, | ||
p.autoReplace, | ||
p.localization, | ||
@@ -476,2 +480,3 @@ p.i18nFn | ||
tolerateWhitespace: p.tolerateWhitespace, | ||
inlineIterators: p.inlineIterators, | ||
@@ -682,5 +687,6 @@ escapeOutput: p.escapeOutput, | ||
el = dir.ignore && dir.ignore.test(el) ? | ||
'' : ' '; | ||
'' : el; | ||
if (el) { | ||
if (el && !dir.tolerateWhitespace) { | ||
el = ' '; | ||
dir.space = true; | ||
@@ -1071,3 +1077,3 @@ } | ||
if (jsDoc) { | ||
dir.save(applyDefEscape(el)); | ||
dir.save(el); | ||
@@ -1263,9 +1269,2 @@ } else if (!dir.tplName) { | ||
// Обратная замена CDATA | ||
dir.res = dir.pasteDangerBlocks(dir.res) | ||
.replace( | ||
/__CDATA__(\d+)_/g, | ||
function(sstr, pos) {return escapeNextLine(dir.cDataContent[pos]).replace(/'/gm, ''')} | ||
); | ||
// Удаление пустых операций | ||
@@ -1307,2 +1306,4 @@ switch (dir.renderMode) { | ||
dir.res += '\n'; | ||
if (p.prettyPrint) { | ||
@@ -1312,3 +1313,9 @@ dir.res = beautify(dir.res); | ||
dir.res += '\n'; | ||
// Обратная замена CDATA | ||
dir.res = dir.pasteDangerBlocks(dir.res) | ||
.replace( | ||
/__CDATA__(\d+)_/g, | ||
function(sstr, pos) {return escapeNextLine(dir.cDataContent[pos]).replace(/'/gm, ''' | ||
)} | ||
); | ||
@@ -1315,0 +1322,0 @@ if (debug) { |
@@ -11,3 +11,3 @@ //#include ./es5shim.live.js | ||
*/ | ||
VERSION: [5, 0, 0], | ||
VERSION: [5, 1, 0], | ||
@@ -14,0 +14,0 @@ /** |
@@ -268,3 +268,3 @@ var aliasRgxp = /__(.*?)__/; | ||
try { | ||
this.evalStr(this.pasteDangerBlocks(res.substring(from, to))); | ||
this.evalStr(res.substring(from, to)); | ||
@@ -271,0 +271,0 @@ } catch (err) { |
@@ -12,3 +12,2 @@ /** | ||
{ | ||
text: true, | ||
block: true, | ||
@@ -15,0 +14,0 @@ selfInclude: false, |
@@ -183,3 +183,3 @@ (function() { | ||
try { | ||
value = this.returnEvalVal(this.pasteDangerBlocks(parts.slice(1).join(' ').trim())); | ||
value = this.returnEvalVal(parts.slice(1).join(' ').trim()); | ||
@@ -186,0 +186,0 @@ } catch (err) { |
@@ -32,4 +32,7 @@ (function() { | ||
this.startInlineDir(); | ||
this.space = true; | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
this.append(this.wrap((("'" + (types[type])) + "'"))); | ||
@@ -36,0 +39,0 @@ } |
@@ -110,3 +110,6 @@ (function() { | ||
function () { | ||
this.space = true; | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
if (this.structure.params.autoReplace) { | ||
@@ -113,0 +116,0 @@ this.autoReplace = true; |
@@ -97,2 +97,15 @@ Snakeskin.addDirective( | ||
Snakeskin.addDirective( | ||
'__sp__', | ||
{ | ||
group: 'ignore', | ||
text: true | ||
}, | ||
function () { | ||
this.startInlineDir(); | ||
} | ||
); | ||
Snakeskin.addDirective( | ||
'__switchLine__', | ||
@@ -99,0 +112,0 @@ |
@@ -234,3 +234,4 @@ /** | ||
language: this.language, | ||
localization: this.localization | ||
localization: this.localization, | ||
tolerateWhitespace: this.tolerateWhitespace | ||
}, | ||
@@ -237,0 +238,0 @@ |
@@ -24,4 +24,7 @@ (function() { | ||
this.startDir(); | ||
this.space = true; | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
if (this.autoReplace) { | ||
@@ -81,3 +84,6 @@ this.autoReplace = false; | ||
function () { | ||
this.space = true; | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
if (this.structure.params.autoReplace) { | ||
@@ -84,0 +90,0 @@ this.autoReplace = true; |
@@ -17,4 +17,7 @@ (function() { | ||
this.startDir(); | ||
this.space = true; | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
if (this.autoReplace) { | ||
@@ -74,3 +77,6 @@ this.autoReplace = false; | ||
function () { | ||
this.space = true; | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
if (this.structure.params.autoReplace) { | ||
@@ -77,0 +83,0 @@ this.autoReplace = true; |
@@ -17,3 +17,2 @@ var emptyCommandParamsRgxp = /^([^\s]+?\(|\()/; | ||
function (command) { | ||
this.space = true; | ||
this.startDir(null, { | ||
@@ -23,2 +22,6 @@ bemRef: this.bemRef | ||
if (!this.tolerateWhitespace) { | ||
this.space = true; | ||
} | ||
if (this.isReady()) { | ||
@@ -36,4 +39,6 @@ if (command) { | ||
var params = this.structure.params; | ||
params.tag = desc.tag; | ||
params.block = !inlineTagMap[desc.tag]; | ||
params.block = inlineTagMap[desc.tag] !== void 0 ? | ||
!inlineTagMap[desc.tag] : !desc.inline; | ||
@@ -81,3 +86,3 @@ var groups = this.splitAttrsGroup(parts.slice(1).join(' ')), | ||
\n if (__TMP__['class']) {\ | ||
\n __NODE__ .className = __TMP__['class'];\ | ||
\n __NODE__.className = __TMP__['class'];\ | ||
\n }\ | ||
@@ -120,3 +125,3 @@ \n\ | ||
* @param {string} str - исходная строка | ||
* @return {{tag: string, id: string, classes: !Array}} | ||
* @return {{tag: string, id: string, classes: !Array, pseudo: !Array, inline: boolean}} | ||
*/ | ||
@@ -127,2 +132,5 @@ DirObj.prototype.returnTagDesc = function (str) { | ||
id = '', | ||
inline = false; | ||
var pseudo = [], | ||
classes = []; | ||
@@ -133,6 +141,12 @@ | ||
var sys = { | ||
'#': true, | ||
'.': true, | ||
':': true | ||
}; | ||
for (var i = -1; ++i < str.length;) { | ||
var el = str.charAt(i); | ||
if (el === '#' || el === '.') { | ||
if (sys[el]) { | ||
if (!tag) { | ||
@@ -146,2 +160,9 @@ tag = 'div'; | ||
classes.push(''); | ||
} else if (el === ':') { | ||
if (!inline) { | ||
inline = pseudo[pseudo.length - 1] === 'inline'; | ||
} | ||
pseudo.push(''); | ||
} | ||
@@ -155,2 +176,3 @@ | ||
id += el; | ||
} break; | ||
@@ -160,4 +182,10 @@ | ||
classes[classes.length - 1] += el; | ||
} break; | ||
case ':': { | ||
pseudo[pseudo.length - 1] += el; | ||
} break; | ||
default: { | ||
@@ -191,2 +219,6 @@ tag += el; | ||
if (!inline) { | ||
inline = pseudo[pseudo.length - 1] === 'inline'; | ||
} | ||
return { | ||
@@ -196,4 +228,6 @@ ref: ref, | ||
id: this.replaceTplVars(id), | ||
classes: classes | ||
classes: classes, | ||
pseudo: pseudo, | ||
inline: inline | ||
}; | ||
}; |
@@ -124,3 +124,8 @@ /** | ||
if (custom) { | ||
str += (("['" + (this.returnEvalVal(this.pasteDangerBlocks(this.prepareOutput(el, true))))) + "']"); | ||
str += (("['" + (applyDefEscape( | ||
this.returnEvalVal( | ||
this.prepareOutput(el, true) | ||
) | ||
))) + "']"); | ||
continue; | ||
@@ -249,3 +254,7 @@ } | ||
try { | ||
str = (("['" + (this.returnEvalVal(this.pasteDangerBlocks(this.prepareOutput(str.substring(1), true))))) + "']"); | ||
str = (("['" + (applyDefEscape( | ||
this.returnEvalVal( | ||
this.prepareOutput(str.substring(1), true) | ||
) | ||
))) + "']"); | ||
@@ -284,3 +293,7 @@ } catch (err) { | ||
try { | ||
str += (("['" + (this.returnEvalVal(this.pasteDangerBlocks(this.prepareOutput(el, true))))) + "']"); | ||
str += (("['" + (applyDefEscape( | ||
this.returnEvalVal( | ||
this.prepareOutput(el, true) | ||
) | ||
))) + "']"); | ||
@@ -433,4 +446,4 @@ } catch (err) { | ||
\n\ | ||
\n var TPL_NAME = '" + (applyDefEscape(tplName))) + ("',\ | ||
\n PARENT_TPL_NAME" + (parentTplName ? ((" = '" + (applyDefEscape(this.pasteDangerBlocks(parentTplName)))) + "'") : '')) + (";\ | ||
\n var TPL_NAME = \"" + (escapeDoubleQuote(tplName))) + ("\",\ | ||
\n PARENT_TPL_NAME" + (parentTplName ? ((" = \"" + (escapeDoubleQuote(parentTplName))) + "\"") : '')) + (";\ | ||
\n\ | ||
@@ -556,3 +569,3 @@ \n " + (args.defParams)) + "\ | ||
\n\ | ||
\n Snakeskin.cache['" + (applyDefEscape(this.pasteDangerBlocks(tplName)))) + ("'] = this" + (concatProp(tplName))) + ";\ | ||
\n Snakeskin.cache[\"" + (escapeDoubleQuote(tplName))) + ("\"] = this" + (concatProp(tplName))) + ";\ | ||
\n ")); | ||
@@ -559,0 +572,0 @@ } |
{ | ||
"name": "snakeskin", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"main": "snakeskin.js", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -87,2 +87,4 @@ module.exports = exports = require('./build/snakeskin.min'); | ||
exports.compileFile = function (src, opt_params) {var this$0 = this; | ||
src = path.normalize(path.resolve(src)); | ||
var p = opt_params || {}; | ||
@@ -170,2 +172,23 @@ p.commonJS = true; | ||
/** | ||
* Вернуть ссылку на главный шаблон | ||
* | ||
* @param {!Object} tpls - таблица шаблонов | ||
* @param {?string=} [opt_src] - путь к файлу шаблонов | ||
* @param {?string=} [opt_tplName] - имя главного шаблона | ||
* @return {Function} | ||
*/ | ||
exports.returnMainTpl = function (tpls, opt_src, opt_tplName) { | ||
var tpl; | ||
if (opt_tplName) { | ||
tpl = tpls[opt_tplName]; | ||
} else { | ||
tpl = tpls[path.basename(opt_src, path.extname(opt_src))] || tpls.main || tpls.index || tpls[Object.keys(tpls)[0]]; | ||
} | ||
return tpl || null; | ||
}; | ||
/** | ||
* Скомпилировать заданный файл и вернуть ссылку на главный шаблон (функцию) | ||
@@ -182,4 +205,3 @@ * | ||
exports.execFile = function (src, opt_params, opt_tplName) { | ||
var tpls = this.compileFile(src, opt_params), | ||
tpl; | ||
var tpls = this.compileFile(src, opt_params); | ||
@@ -190,10 +212,3 @@ if (!tpls) { | ||
if (opt_tplName) { | ||
tpl = tpls[opt_tplName]; | ||
} else { | ||
tpl = tpls[path.basename(src, path.extname(src))] || tpls.main || tpls.index || tpls[Object.keys(tpls)[0]]; | ||
} | ||
return tpl || null; | ||
return this.returnMainTpl(tpls, src, opt_tplName); | ||
}; | ||
@@ -213,4 +228,3 @@ | ||
exports.exec = function (txt, opt_params, opt_tplName) { | ||
var tpls = {}, | ||
tpl; | ||
var tpls = {}; | ||
@@ -221,15 +235,3 @@ opt_params = opt_params || {}; | ||
this.compile(txt, opt_params); | ||
if (!tpls) { | ||
return null; | ||
} | ||
if (opt_tplName) { | ||
tpl = tpls[opt_tplName]; | ||
} else { | ||
tpl = tpls.main || tpls.index || tpls[Object.keys(tpls)[0]]; | ||
} | ||
return tpl || null; | ||
return this.returnMainTpl(tpls, null, opt_tplName); | ||
}; |
@@ -39,3 +39,3 @@ var path = require('path'); | ||
var starts = txt[0].split(/[\n\r]+/), | ||
var starts = txt[0].split(/[\r\n]+/), | ||
results = txt[2].split('***'); | ||
@@ -42,0 +42,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* Snakeskin v5.0.0, key <true,true,false,,stringConcat,true,true,,false,true,i18n>, label <1411991994660>, includes <>, generated at <1411991997531>. | ||
/* Snakeskin v5.1.0, key <true,false,true,false,false,,stringConcat,true,true,,false,true,i18n>, label <1412075169909>, includes <>, generated at <1412243211969>. | ||
This code is generated automatically, don't alter it. */ | ||
@@ -24,3 +24,3 @@ (function() { | ||
__STR__, __TMP__, __J__; | ||
var $_ = __LOCAL__['$_9e336']; /* Snakeskin template: test; asserts */ | ||
var $_ = __LOCAL__['$_e133c']; /* Snakeskin template: test; asserts */ | ||
this.test = function(asserts) { | ||
@@ -46,8 +46,8 @@ var __THIS__ = this, | ||
function clearTplResult() { | ||
__RESULT__ = ''; | ||
} | ||
__RESULT__ = ''; | ||
} | ||
var __RETURN__ = false, | ||
__RETURN_VAL__; | ||
var TPL_NAME = 'test', | ||
PARENT_TPL_NAME; | ||
__RETURN_VAL__; | ||
var TPL_NAME = "test", | ||
PARENT_TPL_NAME; | ||
__RESULT__ += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset="utf-8"" /> <title>Snakeskin.compile</title> <link type="text/css" rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.13.0.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script> <script type="text/javascript" src="../build/snakeskin.min.js"></script> <script type="text/javascript"> Object.create = Object.create || function (obj) { function F() { }; F.prototype = obj; return new F(); }; function i18n(str) { return str; } </script> </head> <body> <h1 id="qunit-header">Test: Snakeskin.compile</h1> <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"></ol> '; | ||
@@ -75,6 +75,6 @@ Snakeskin.forEach(asserts, function(__el__forEach_1147) { | ||
__RESULT__ += '</body> </html> '; | ||
return __RESULT__; | ||
}; | ||
Snakeskin.cache['test'] = this.test; /* Snakeskin template. */ | ||
return __RESULT__; | ||
}; | ||
Snakeskin.cache["test"] = this.test; /* Snakeskin template. */ | ||
} | ||
}).call(this); | ||
}).call(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
1276817
24873