Comparing version 2.3.19 to 2.3.20
# riot-tmpl Changes | ||
### v2.3.20 | ||
- Fixed lint issues with new .eslint.yml, almost compatible with [JavaScript Standard Style](http://standardjs.com/) | ||
### v2.3.19 | ||
- Fixing issues with double quotes. | ||
- Fixed issues with double quotes. | ||
@@ -6,0 +9,0 @@ ### v2.3.18 |
/** | ||
* The riot template engine | ||
* @version v2.3.19 | ||
* @version v2.3.20 | ||
*/ | ||
@@ -15,2 +15,3 @@ | ||
export | ||
var brackets = (function (UNDEF) { | ||
@@ -41,5 +42,5 @@ | ||
function _loopback(re) { return re } | ||
function _loopback (re) { return re } | ||
function _rewrite(re, bp) { | ||
function _rewrite (re, bp) { | ||
if (!bp) bp = _pairs | ||
@@ -51,3 +52,3 @@ return new RegExp( | ||
function _create(pair) { | ||
function _create (pair) { | ||
var | ||
@@ -77,3 +78,3 @@ cvt, | ||
function _reset(pair) { | ||
function _reset (pair) { | ||
if (!pair) pair = DEFAULT | ||
@@ -91,7 +92,7 @@ | ||
function _brackets(reOrIdx) { | ||
function _brackets (reOrIdx) { | ||
return reOrIdx instanceof RegExp ? _regex(reOrIdx) : _pairs[reOrIdx] | ||
} | ||
_brackets.split = function split(str, tmpl, _bp) { | ||
_brackets.split = function split (str, tmpl, _bp) { | ||
// istanbul ignore next: _bp is for the compiler | ||
@@ -139,3 +140,3 @@ if (!_bp) _bp = _pairs | ||
function unescapeStr(str) { | ||
function unescapeStr (str) { | ||
if (tmpl || isexpr) | ||
@@ -147,3 +148,3 @@ parts.push(str && str.replace(_bp[5], '$1')) | ||
function skipBraces(ch, pos) { | ||
function skipBraces (ch, pos) { | ||
var | ||
@@ -163,7 +164,7 @@ match, | ||
_brackets.hasExpr = function hasExpr(str) { | ||
_brackets.hasExpr = function hasExpr (str) { | ||
return _brackets(4).test(str) | ||
} | ||
_brackets.loopKeys = function loopKeys(expr) { | ||
_brackets.loopKeys = function loopKeys (expr) { | ||
var m = expr.match(_brackets(9)) | ||
@@ -174,3 +175,3 @@ return m ? | ||
_brackets.array = function array(pair) { | ||
_brackets.array = function array (pair) { | ||
return _create(pair || cachedBrackets) | ||
@@ -180,3 +181,3 @@ } | ||
var _settings | ||
function _setSettings(o) { | ||
function _setSettings (o) { | ||
var b | ||
@@ -217,3 +218,5 @@ o = o || {} | ||
*/ | ||
/*global riot */ | ||
export | ||
var tmpl = (function () { | ||
@@ -223,3 +226,3 @@ | ||
function _tmpl(str, data) { | ||
function _tmpl (str, data) { | ||
if (!str) return str | ||
@@ -231,3 +234,3 @@ | ||
_tmpl.isRaw = function (expr) { | ||
return expr[brackets._rawOffset] === "=" | ||
return expr[brackets._rawOffset] === '=' | ||
} | ||
@@ -245,3 +248,3 @@ | ||
function _logErr(err, ctx) { | ||
function _logErr (err, ctx) { | ||
@@ -258,3 +261,3 @@ if (_tmpl.errorHandler) { | ||
function _create(str) { | ||
function _create (str) { | ||
@@ -271,3 +274,3 @@ var expr = _getTmpl(str) | ||
function _getTmpl(str) { | ||
function _getTmpl (str) { | ||
var | ||
@@ -318,8 +321,7 @@ qstr = [], | ||
var | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/, | ||
RE_BRACE = /,|([[{(])|$/g | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/ | ||
function _parseExpr(expr, asText, qstr) { | ||
function _parseExpr (expr, asText, qstr) { | ||
if (expr[0] === "=") expr = expr.slice(1) | ||
if (expr[0] === '=') expr = expr.slice(1) | ||
@@ -364,3 +366,3 @@ expr = expr | ||
function skipBraces(jsb, re) { | ||
function skipBraces (jsb, re) { | ||
var | ||
@@ -381,6 +383,8 @@ match, | ||
// istanbul ignore next: not both | ||
var JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').' | ||
var JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g | ||
var | ||
JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').', | ||
JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g, | ||
JS_NOPROPS = /^(?=(\.[$\w]+))\1(?:[^.[(]|$)/ | ||
function _wrapExpr(expr, asText, key) { | ||
function _wrapExpr (expr, asText, key) { | ||
var tb | ||
@@ -396,4 +400,5 @@ | ||
} | ||
else if (pos) | ||
tb = !/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/.test(s.slice(pos)) | ||
else if (pos) { | ||
tb = !JS_NOPROPS.test(s.slice(pos)) | ||
} | ||
} | ||
@@ -430,5 +435,3 @@ return match | ||
tmpl.version = brackets.version = 'v2.3.19' | ||
tmpl.version = brackets.version = 'v2.3.20' | ||
export default {tmpl, brackets} | ||
/** | ||
* The riot template engine | ||
* @version v2.3.19 | ||
* @version v2.3.20 | ||
*/ | ||
@@ -14,2 +14,3 @@ | ||
*/ | ||
/*global riot */ | ||
@@ -41,5 +42,5 @@ var brackets = (function (UNDEF) { | ||
function _loopback(re) { return re } | ||
function _loopback (re) { return re } | ||
function _rewrite(re, bp) { | ||
function _rewrite (re, bp) { | ||
if (!bp) bp = _pairs | ||
@@ -51,3 +52,3 @@ return new RegExp( | ||
function _create(pair) { | ||
function _create (pair) { | ||
var | ||
@@ -77,3 +78,3 @@ cvt, | ||
function _reset(pair) { | ||
function _reset (pair) { | ||
if (!pair) pair = DEFAULT | ||
@@ -91,7 +92,7 @@ | ||
function _brackets(reOrIdx) { | ||
function _brackets (reOrIdx) { | ||
return reOrIdx instanceof RegExp ? _regex(reOrIdx) : _pairs[reOrIdx] | ||
} | ||
_brackets.split = function split(str, tmpl, _bp) { | ||
_brackets.split = function split (str, tmpl, _bp) { | ||
// istanbul ignore next: _bp is for the compiler | ||
@@ -139,3 +140,3 @@ if (!_bp) _bp = _pairs | ||
function unescapeStr(str) { | ||
function unescapeStr (str) { | ||
if (tmpl || isexpr) | ||
@@ -147,3 +148,3 @@ parts.push(str && str.replace(_bp[5], '$1')) | ||
function skipBraces(ch, pos) { | ||
function skipBraces (ch, pos) { | ||
var | ||
@@ -163,7 +164,7 @@ match, | ||
_brackets.hasExpr = function hasExpr(str) { | ||
_brackets.hasExpr = function hasExpr (str) { | ||
return _brackets(4).test(str) | ||
} | ||
_brackets.loopKeys = function loopKeys(expr) { | ||
_brackets.loopKeys = function loopKeys (expr) { | ||
var m = expr.match(_brackets(9)) | ||
@@ -174,3 +175,3 @@ return m ? | ||
_brackets.array = function array(pair) { | ||
_brackets.array = function array (pair) { | ||
return _create(pair || cachedBrackets) | ||
@@ -180,3 +181,3 @@ } | ||
var _settings | ||
function _setSettings(o) { | ||
function _setSettings (o) { | ||
var b | ||
@@ -217,2 +218,3 @@ o = o || {} | ||
*/ | ||
/*global riot */ | ||
@@ -223,3 +225,3 @@ var tmpl = (function () { | ||
function _tmpl(str, data) { | ||
function _tmpl (str, data) { | ||
if (!str) return str | ||
@@ -231,3 +233,3 @@ | ||
_tmpl.isRaw = function (expr) { | ||
return expr[brackets._rawOffset] === "=" | ||
return expr[brackets._rawOffset] === '=' | ||
} | ||
@@ -245,3 +247,3 @@ | ||
function _logErr(err, ctx) { | ||
function _logErr (err, ctx) { | ||
@@ -258,3 +260,3 @@ if (_tmpl.errorHandler) { | ||
function _create(str) { | ||
function _create (str) { | ||
@@ -271,3 +273,3 @@ var expr = _getTmpl(str) | ||
function _getTmpl(str) { | ||
function _getTmpl (str) { | ||
var | ||
@@ -318,8 +320,7 @@ qstr = [], | ||
var | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/, | ||
RE_BRACE = /,|([[{(])|$/g | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/ | ||
function _parseExpr(expr, asText, qstr) { | ||
function _parseExpr (expr, asText, qstr) { | ||
if (expr[0] === "=") expr = expr.slice(1) | ||
if (expr[0] === '=') expr = expr.slice(1) | ||
@@ -364,3 +365,3 @@ expr = expr | ||
function skipBraces(jsb, re) { | ||
function skipBraces (jsb, re) { | ||
var | ||
@@ -381,6 +382,8 @@ match, | ||
// istanbul ignore next: not both | ||
var JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').' | ||
var JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g | ||
var | ||
JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').', | ||
JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g, | ||
JS_NOPROPS = /^(?=(\.[$\w]+))\1(?:[^.[(]|$)/ | ||
function _wrapExpr(expr, asText, key) { | ||
function _wrapExpr (expr, asText, key) { | ||
var tb | ||
@@ -396,4 +399,5 @@ | ||
} | ||
else if (pos) | ||
tb = !/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/.test(s.slice(pos)) | ||
else if (pos) { | ||
tb = !JS_NOPROPS.test(s.slice(pos)) | ||
} | ||
} | ||
@@ -430,3 +434,3 @@ return match | ||
tmpl.version = brackets.version = 'v2.3.19' | ||
tmpl.version = brackets.version = 'v2.3.20' | ||
@@ -1,4 +0,5 @@ | ||
/* riot-tmpl v2.3.19, @license MIT, (c) 2015 Muut Inc. + contributors */ | ||
;(function (window) { | ||
'use strict' // eslint-disable-line | ||
/* riot-tmpl v2.3.20, @license MIT, (c) 2015 Muut Inc. + contributors */ | ||
;(function (window) { // eslint-disable-line no-extra-semi | ||
'use strict' | ||
/*eslint-env amd */ | ||
@@ -38,5 +39,5 @@ /** | ||
function _loopback(re) { return re } | ||
function _loopback (re) { return re } | ||
function _rewrite(re, bp) { | ||
function _rewrite (re, bp) { | ||
if (!bp) bp = _pairs | ||
@@ -48,3 +49,3 @@ return new RegExp( | ||
function _create(pair) { | ||
function _create (pair) { | ||
var | ||
@@ -74,3 +75,3 @@ cvt, | ||
function _reset(pair) { | ||
function _reset (pair) { | ||
if (!pair) pair = DEFAULT | ||
@@ -88,7 +89,7 @@ | ||
function _brackets(reOrIdx) { | ||
function _brackets (reOrIdx) { | ||
return reOrIdx instanceof RegExp ? _regex(reOrIdx) : _pairs[reOrIdx] | ||
} | ||
_brackets.split = function split(str, tmpl, _bp) { | ||
_brackets.split = function split (str, tmpl, _bp) { | ||
// istanbul ignore next: _bp is for the compiler | ||
@@ -136,3 +137,3 @@ if (!_bp) _bp = _pairs | ||
function unescapeStr(str) { | ||
function unescapeStr (str) { | ||
if (tmpl || isexpr) | ||
@@ -144,3 +145,3 @@ parts.push(str && str.replace(_bp[5], '$1')) | ||
function skipBraces(ch, pos) { | ||
function skipBraces (ch, pos) { | ||
var | ||
@@ -160,7 +161,7 @@ match, | ||
_brackets.hasExpr = function hasExpr(str) { | ||
_brackets.hasExpr = function hasExpr (str) { | ||
return _brackets(4).test(str) | ||
} | ||
_brackets.loopKeys = function loopKeys(expr) { | ||
_brackets.loopKeys = function loopKeys (expr) { | ||
var m = expr.match(_brackets(9)) | ||
@@ -171,3 +172,3 @@ return m ? | ||
_brackets.array = function array(pair) { | ||
_brackets.array = function array (pair) { | ||
return _create(pair || cachedBrackets) | ||
@@ -177,3 +178,3 @@ } | ||
var _settings | ||
function _setSettings(o) { | ||
function _setSettings (o) { | ||
var b | ||
@@ -214,2 +215,3 @@ o = o || {} | ||
*/ | ||
/*global riot */ | ||
@@ -220,3 +222,3 @@ var tmpl = (function () { | ||
function _tmpl(str, data) { | ||
function _tmpl (str, data) { | ||
if (!str) return str | ||
@@ -228,3 +230,3 @@ | ||
_tmpl.isRaw = function (expr) { | ||
return expr[brackets._rawOffset] === "=" | ||
return expr[brackets._rawOffset] === '=' | ||
} | ||
@@ -242,3 +244,3 @@ | ||
function _logErr(err, ctx) { | ||
function _logErr (err, ctx) { | ||
@@ -255,3 +257,3 @@ if (_tmpl.errorHandler) { | ||
function _create(str) { | ||
function _create (str) { | ||
@@ -268,3 +270,3 @@ var expr = _getTmpl(str) | ||
function _getTmpl(str) { | ||
function _getTmpl (str) { | ||
var | ||
@@ -315,8 +317,7 @@ qstr = [], | ||
var | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/, | ||
RE_BRACE = /,|([[{(])|$/g | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/ | ||
function _parseExpr(expr, asText, qstr) { | ||
function _parseExpr (expr, asText, qstr) { | ||
if (expr[0] === "=") expr = expr.slice(1) | ||
if (expr[0] === '=') expr = expr.slice(1) | ||
@@ -361,3 +362,3 @@ expr = expr | ||
function skipBraces(jsb, re) { | ||
function skipBraces (jsb, re) { | ||
var | ||
@@ -378,6 +379,8 @@ match, | ||
// istanbul ignore next: not both | ||
var JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').' | ||
var JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g | ||
var | ||
JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').', | ||
JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g, | ||
JS_NOPROPS = /^(?=(\.[$\w]+))\1(?:[^.[(]|$)/ | ||
function _wrapExpr(expr, asText, key) { | ||
function _wrapExpr (expr, asText, key) { | ||
var tb | ||
@@ -393,4 +396,5 @@ | ||
} | ||
else if (pos) | ||
tb = !/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/.test(s.slice(pos)) | ||
else if (pos) { | ||
tb = !JS_NOPROPS.test(s.slice(pos)) | ||
} | ||
} | ||
@@ -427,3 +431,3 @@ return match | ||
tmpl.version = brackets.version = 'v2.3.19' | ||
tmpl.version = brackets.version = 'v2.3.20' | ||
@@ -439,3 +443,3 @@ /* istanbul ignore else */ | ||
return { | ||
'tmpl': tmpl, 'brackets': breackets | ||
'tmpl': tmpl, 'brackets': brackets | ||
} | ||
@@ -449,3 +453,2 @@ }) | ||
})(typeof window === 'object' ? /* istanbul ignore next */ window : void 0) // eslint-disable-line no-void | ||
})(typeof window === 'object' ? /* istanbul ignore next */ window : void 0) // eslint-disable-line |
@@ -27,11 +27,9 @@ | ||
<script type="riot/tag"> | ||
<mytag><p>{ foo == 'bar' }</p></mytag> | ||
<mytag><p>{ foo.bar }</p></mytag> | ||
</script> | ||
<script> | ||
riot.util.tmpl.errorHandler = myLogger | ||
riot.util.tmpl.errorHandler = function (err) { | ||
console.error(err.message + ' in ' + err.riotData.tagName) | ||
} | ||
riot.mount('*') | ||
function myLogger(err) { | ||
console.log(err.message + ' in ' + err.riotData.tagName) | ||
} | ||
</script> | ||
@@ -38,0 +36,0 @@ ``` |
@@ -8,2 +8,8 @@ /** | ||
*/ | ||
//#if 0 // only in the unprocessed source | ||
/*eslint no-unused-vars: [2, {args: "after-used", varsIgnorePattern: "^brackets$"}] */ | ||
//#if RIOT | ||
/*global riot */ | ||
//#endif | ||
//#endif | ||
@@ -28,4 +34,6 @@ //#set $_RIX_TEST = 4 | ||
//#if ES6 | ||
export | ||
//#endif | ||
var brackets = (function (UNDEF) { | ||
// Closure data | ||
@@ -78,3 +86,3 @@ // -------------------------------------------------------------------------- | ||
*/ | ||
function _loopback(re) { return re } | ||
function _loopback (re) { return re } | ||
@@ -88,3 +96,3 @@ /** | ||
*/ | ||
function _rewrite(re, bp) { | ||
function _rewrite (re, bp) { | ||
if (!bp) bp = _pairs | ||
@@ -103,3 +111,3 @@ return new RegExp( | ||
*/ | ||
function _create(pair) { | ||
function _create (pair) { | ||
var | ||
@@ -135,3 +143,3 @@ cvt, | ||
*/ | ||
function _reset(pair) { | ||
function _reset (pair) { | ||
if (!pair) pair = DEFAULT | ||
@@ -161,3 +169,3 @@ | ||
*/ | ||
function _brackets(reOrIdx) { | ||
function _brackets (reOrIdx) { | ||
return reOrIdx instanceof RegExp ? _regex(reOrIdx) : _pairs[reOrIdx] | ||
@@ -176,3 +184,3 @@ } | ||
*/ | ||
_brackets.split = function split(str, tmpl, _bp) { | ||
_brackets.split = function split (str, tmpl, _bp) { | ||
// istanbul ignore next: _bp is for the compiler | ||
@@ -243,3 +251,3 @@ if (!_bp) _bp = _pairs | ||
// tmpl, from the HTML part too. | ||
function unescapeStr(str) { | ||
function unescapeStr (str) { | ||
if (tmpl || isexpr) | ||
@@ -253,3 +261,3 @@ parts.push(str && str.replace(_bp[$_RIX_ESC], '$1')) | ||
// Skips strings, regexes, and other inner blocks. | ||
function skipBraces(ch, pos) { | ||
function skipBraces (ch, pos) { | ||
var | ||
@@ -269,7 +277,7 @@ match, | ||
_brackets.hasExpr = function hasExpr(str) { | ||
_brackets.hasExpr = function hasExpr (str) { | ||
return _brackets($_RIX_TEST).test(str) | ||
} | ||
_brackets.loopKeys = function loopKeys(expr) { | ||
_brackets.loopKeys = function loopKeys (expr) { | ||
var m = expr.match(_brackets($_RIX_LOOP)) | ||
@@ -288,3 +296,3 @@ return m ? | ||
*/ | ||
_brackets.array = function array(pair) { | ||
_brackets.array = function array (pair) { | ||
return _create(pair || cachedBrackets) // fix #1314 | ||
@@ -298,3 +306,3 @@ } | ||
var _settings | ||
function _setSettings(o) { | ||
function _setSettings (o) { | ||
var b | ||
@@ -327,2 +335,2 @@ o = o || {} | ||
})() | ||
})() |
@@ -0,5 +1,9 @@ | ||
//#if 0 | ||
/*global tmpl, brackets */ | ||
//#endif | ||
//#if NODE | ||
/* riot-tmpl WIP, @license MIT, (c) 2015 Muut Inc. + contributors */ | ||
;(function (window) { | ||
'use strict' // eslint-disable-line | ||
;(function (window) { // eslint-disable-line no-extra-semi | ||
'use strict' | ||
/*eslint-env amd */ | ||
//#else | ||
@@ -31,3 +35,3 @@ | ||
return { | ||
'tmpl': tmpl, 'brackets': breackets | ||
'tmpl': tmpl, 'brackets': brackets | ||
} | ||
@@ -41,8 +45,3 @@ }) | ||
})(typeof window === 'object' ? /* istanbul ignore next */ window : void 0) // eslint-disable-line no-void | ||
//#elif ES6 | ||
export default {tmpl, brackets} | ||
})(typeof window === 'object' ? /* istanbul ignore next */ window : void 0) // eslint-disable-line | ||
//#endif |
@@ -8,5 +8,13 @@ /** | ||
*/ | ||
/*global riot */ | ||
//#if 0 // only in the unprocessed source | ||
/*eslint no-unused-vars: [2, {args: "after-used", varsIgnorePattern: "tmpl"}] */ | ||
/*global brackets */ | ||
//#endif | ||
//#define LIST_GETTERS 0 | ||
// IIFE for tmpl() | ||
//#if ES6 | ||
export | ||
//#endif | ||
var tmpl = (function () { | ||
@@ -18,7 +26,5 @@ | ||
//#set $_RAW_FLAG = '=' | ||
//#set $_RIX_RAW = 10 | ||
//#if !$_RAW_FLAG | ||
var $_RAW_FLAG = '=' | ||
var $_RIX_RAW = 10 | ||
//#set $_RIX_RAW = 10 | ||
//#if !$_RIX_RAW | ||
var $_RIX_RAW = 10 | ||
//#endif | ||
@@ -37,6 +43,7 @@ | ||
*/ | ||
function _tmpl(str, data) { | ||
function _tmpl (str, data) { | ||
if (!str) return str // catch falsy values here | ||
//#if DEBUG | ||
/*eslint no-console: 0 */ | ||
if (data && data._debug_) { | ||
@@ -68,3 +75,3 @@ data._debug_ = 0 | ||
_tmpl.isRaw = function (expr) { | ||
return expr[brackets._rawOffset] === $_RAW_FLAG | ||
return expr[brackets._rawOffset] === '=' | ||
} | ||
@@ -112,3 +119,3 @@ | ||
*/ | ||
function _logErr(err, ctx) { | ||
function _logErr (err, ctx) { | ||
@@ -132,3 +139,3 @@ if (_tmpl.errorHandler) { | ||
*/ | ||
function _create(str) { | ||
function _create (str) { | ||
@@ -169,3 +176,3 @@ var expr = _getTmpl(str) | ||
*/ | ||
function _getTmpl(str) { | ||
function _getTmpl (str) { | ||
var | ||
@@ -232,4 +239,3 @@ qstr = [], // hidden qblocks | ||
var | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/, | ||
RE_BRACE = /,|([[{(])|$/g | ||
CS_IDENT = /^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\x01(\d+)~):/ | ||
@@ -245,3 +251,3 @@ /** | ||
*/ | ||
function _parseExpr(expr, asText, qstr) { | ||
function _parseExpr (expr, asText, qstr) { | ||
@@ -260,3 +266,3 @@ // Replace non-empty qstrings with a marker that includes its index into the array | ||
if (expr[0] === $_RAW_FLAG) expr = expr.slice(1) | ||
if (expr[0] === '=') expr = expr.slice(1) | ||
@@ -308,3 +314,3 @@ expr = expr | ||
// Skip bracketed block, uses the str value in the closure | ||
function skipBraces(jsb, re) { | ||
function skipBraces (jsb, re) { | ||
var | ||
@@ -326,7 +332,9 @@ match, | ||
// istanbul ignore next: not both | ||
var JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').' | ||
var JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g | ||
var | ||
JS_CONTEXT = '"in this?this:' + (typeof window !== 'object' ? 'global' : 'window') + ').', | ||
JS_VARNAME = /[,{][$\w]+:|(^ *|[^$\w\.])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g, | ||
JS_NOPROPS = /^(?=(\.[$\w]+))\1(?:[^.[(]|$)/ | ||
// Generates code to evaluate an expression avoiding breaking on undefined vars. | ||
function _wrapExpr(expr, asText, key) { | ||
function _wrapExpr (expr, asText, key) { | ||
var tb | ||
@@ -343,4 +351,5 @@ | ||
} | ||
else if (pos) | ||
tb = !/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/.test(s.slice(pos)) | ||
else if (pos) { | ||
tb = !JS_NOPROPS.test(s.slice(pos)) // needs try..catch block? | ||
} | ||
} | ||
@@ -347,0 +356,0 @@ return match |
{ | ||
"name": "riot-tmpl", | ||
"version": "2.3.19", | ||
"version": "2.3.20", | ||
"description": "The riot template engine", | ||
@@ -19,3 +19,3 @@ "main": "dist/tmpl.js", | ||
"test": "make test", | ||
"prepublish": "make build && node bump" | ||
"prepublish": "make build && ./node_modules/.bin/riot-bump" | ||
}, | ||
@@ -37,3 +37,3 @@ "repository": { | ||
"istanbul": "^0.4.1", | ||
"jspreproc": "^0.2.5", | ||
"jspreproc": "^0.2.7", | ||
"karma": "^0.13.15", | ||
@@ -45,3 +45,4 @@ "karma-browserstack-launcher": "^0.1.6", | ||
"mocha": "^2.3.4", | ||
"phantomjs": "^1.9.19" | ||
"phantomjs": "^1.9.19", | ||
"riot-bump": "^1.0.0" | ||
}, | ||
@@ -48,0 +49,0 @@ "author": "Muut, Inc. and other contributors", |
@@ -9,3 +9,3 @@ module.exports = function (config) { | ||
browsers = Object.keys(customLaunchers) | ||
browsers.forEach(function(browser) { customLaunchers[browser].base = 'BrowserStack' }) | ||
browsers.forEach(function (browser) { customLaunchers[browser].base = 'BrowserStack' }) | ||
} | ||
@@ -12,0 +12,0 @@ else |
@@ -1,9 +0,7 @@ | ||
'use strict' // eslint-disable-line strict, global-strict | ||
/*eslint no-console: 0 */ | ||
'use strict' // eslint-disable-line | ||
var | ||
tmpl23 = require('../dist/tmpl').tmpl, | ||
tmpl22 = require('./v223/tmpl223.js').tmpl, | ||
//assert = require('assert'), | ||
path = require('path'), | ||
fs = require('fs') | ||
tmpl22 = require('./v223/tmpl223.js').tmpl | ||
@@ -67,3 +65,3 @@ var | ||
function testExpr(tmpl, data, times, list, agc) { | ||
function testExpr (tmpl, data, times, list, agc) { | ||
var ogc, gc1, gc2, gc3 | ||
@@ -109,18 +107,18 @@ times.length = 0 | ||
function numsort(a, b) { | ||
function numsort (a, b) { | ||
return a - b | ||
} | ||
function numsum(a, b) { | ||
function numsum (a, b) { | ||
return a + b | ||
} | ||
function replicate(s, n) { | ||
function replicate (s, n) { | ||
return n < 1 ? '' : (new Array(n + 1)).join(s) | ||
} | ||
function padr(s, n) { | ||
function padr (s, n) { | ||
s = '' + s | ||
return s + replicate(' ', n - s.length) | ||
} | ||
function padl(s, n) { | ||
function padl (s, n) { | ||
s = '' + s | ||
return replicate(' ', n - s.length) + s | ||
} |
var isNode = typeof window === 'undefined' | ||
describe('Observable Tests', function() { | ||
describe('Observable Tests', function () { | ||
if (isNode) { | ||
@@ -5,0 +5,0 @@ expect = require('expect.js') |
@@ -1,8 +0,3 @@ | ||
/* | ||
if (typeof tmpl === 'undefined') { | ||
var | ||
expect = require('expect.js'), | ||
tmpl = require('tmpl').tmpl, | ||
brackets = require('tmpl').brackets | ||
}*/ | ||
/*eslint-env mocha */ | ||
/*global riot, tmpl, brackets, expect */ | ||
@@ -14,13 +9,13 @@ describe('brackets', function () { | ||
// send 1 or 2 in 'err' to enable internal information | ||
function render(str, dbg) { | ||
function render (str, dbg) { | ||
if (dbg) data._debug_ = 1 | ||
return tmpl(str, data) | ||
} | ||
function setBrackets(s) { | ||
function setBrackets (s) { | ||
brackets.set(s) | ||
} | ||
function resetBrackets() { | ||
function resetBrackets () { | ||
brackets.set('{ }') | ||
} | ||
function bracketsPair() { | ||
function bracketsPair () { | ||
return brackets(0) + ' ' + brackets(1) | ||
@@ -101,5 +96,5 @@ } | ||
//['<% %>', '<% %>' ], // angle brackets unsupported from 2.4 | ||
['{# #}', '{# #}' ], | ||
['{# #}', '{# #}'], | ||
['[! !]', '\\[! !\\]'], | ||
['·ʃ ʃ', '·ʃ ʃ' ], | ||
['·ʃ ʃ', '·ʃ ʃ'], | ||
['{$ $}', '{\\$ \\$}'], | ||
@@ -323,3 +318,3 @@ ['_( )_', '_\\( \\)_'] | ||
resetBrackets() // set brackets to default | ||
a = brackets.split(str) | ||
var a = brackets.split(str) | ||
@@ -340,3 +335,3 @@ expect(a).to.have.length(9) | ||
resetBrackets() | ||
a = brackets.split(str, true) | ||
var a = brackets.split(str, true) | ||
@@ -363,3 +358,3 @@ expect(a).to.have.length(9) | ||
it('recognizes difficult literal regexes', function () { | ||
var n, i, str, p1 = '<p a="', p2 = '">' | ||
var n, i, p1 = '<p a="', p2 = '">' | ||
var atest = [ | ||
@@ -387,3 +382,3 @@ [p1, '{5+3/ /}/}', p2], // <p a="{a+5/ /}/}"> : regex: /}/ (ok, `5+3/ re` == NaN) | ||
function unq(s) { return /^{.*}$/.test(s) ? s.slice(1, -1) : s } | ||
function unq (s) { return /^{.*}$/.test(s) ? s.slice(1, -1) : s } | ||
}) | ||
@@ -390,0 +385,0 @@ |
@@ -1,3 +0,4 @@ | ||
/* eslint-env node, mocha */ | ||
/* eslint camelcase: 0 */ | ||
/*eslint-env mocha */ | ||
/*eslint camelcase: 0 */ | ||
/*global tmpl, brackets, expect, globalVar:true */ | ||
@@ -16,3 +17,3 @@ globalVar = 5 | ||
esc: '\'\n\\', | ||
fn: function(s) { return ['hi', s].join(' ') }, | ||
fn: function (s) { return ['hi', s].join(' ') }, | ||
_debug_: 0 | ||
@@ -24,3 +25,3 @@ } | ||
// send 1 or 2 in 'err' to enable internal information | ||
function render(str, dbg) { | ||
function render (str, dbg) { | ||
if (dbg) data._debug_ = 1 | ||
@@ -196,3 +197,3 @@ return tmpl(str, data) | ||
data.$a = 5 | ||
expect(render('{' + (typeof window === 'object' ? 'window' : 'global') +'.globalVar }')).to.be(5) | ||
expect(render('{' + (typeof window === 'object' ? 'window' : 'global') + '.globalVar }')).to.be(5) | ||
expect(render('{ this.$a }')).to.be(5) | ||
@@ -294,3 +295,3 @@ expect(render('{ void 0 }')).to.be(undefined) | ||
describe('2.3.0', function() { | ||
describe('2.3.0', function () { | ||
@@ -371,3 +372,3 @@ it('support for 8 bit, ISO-8859-1 charset in shorthand names', function () { | ||
it('using a custom function', function () { | ||
var result, err | ||
var err | ||
tmpl.errorHandler = function (e) { err = e } | ||
@@ -389,3 +390,3 @@ // je, tmpl({x}, NaN) does not generate error... bug or danling var? | ||
it('GOTCHA: null as param for call([this]) defaults to global too', function () { | ||
var result, err | ||
var err | ||
tmpl.errorHandler = function (e) { err = e } | ||
@@ -439,3 +440,3 @@ err = 0 | ||
it('tmpl.loopKeys: extract keys from the value (for `each`)', function () { | ||
var i, s, | ||
var i, | ||
atest = [ | ||
@@ -459,3 +460,3 @@ '{ studio in studios["Nearby Locations"] }', {key: 'studio', pos: undefined, val: '{studios["Nearby Locations"]}'}, | ||
brackets.set('{{ }}') | ||
var i, s, | ||
var i, | ||
atest = [ | ||
@@ -462,0 +463,0 @@ '{{k,i in item}}', {key: 'k', pos: 'i', val: '{{item}}'}, |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
118840
2750
1
13