riot-tmpl
Advanced tools
Comparing version 2.4.2 to 3.0.0-rc
# riot-tmpl Changes | ||
### v3.0.0 | ||
- Change output all the template errors in the console using `console.error` | ||
### v2.4.2 | ||
@@ -4,0 +7,0 @@ - Fix [riot#2002](https://github.com/riot/riot/issues/2002) : getting `Unexpected token '('. Expected a property name.` inside riot.js code (bug present in iOS 9.3.0) |
/** | ||
* The riot template engine | ||
* @version v2.4.2 | ||
* @version v3.0.0-rc | ||
*/ | ||
@@ -233,4 +233,2 @@ /** | ||
_tmpl.haveRaw = brackets.hasRaw | ||
_tmpl.hasExpr = brackets.hasExpr | ||
@@ -247,9 +245,17 @@ | ||
if (_tmpl.errorHandler) { | ||
err.riotData = { | ||
tagName: ctx && ctx.root && ctx.root.tagName, | ||
_riot_id: ctx && ctx._riot_id //eslint-disable-line camelcase | ||
} | ||
err.riotData = { | ||
tagName: ctx && ctx.root && ctx.root.tagName, | ||
_riot_id: ctx && ctx._riot_id //eslint-disable-line camelcase | ||
if (_tmpl.errorHandler) _tmpl.errorHandler(err) | ||
if ( | ||
typeof console !== 'undefined' && | ||
typeof console.error === 'function' | ||
) { | ||
if (err.riotData.tagName) { | ||
console.error('Riot template error thrown in the <%s> tag', err.riotData.tagName) | ||
} | ||
_tmpl.errorHandler(err) | ||
console.error(err) | ||
} | ||
@@ -423,3 +429,3 @@ } | ||
_tmpl.version = brackets.version = 'v2.4.2' | ||
_tmpl.version = brackets.version = 'v3.0.0-rc' | ||
@@ -426,0 +432,0 @@ return _tmpl |
/* riot-tmpl v2.4.2, @license MIT, (c) 2015 Muut Inc. + contributors */ | ||
/* riot-tmpl v3.0.0-rc, @license MIT, (c) 2015 Muut Inc. + contributors */ | ||
;(function (window) { // eslint-disable-line no-extra-semi | ||
@@ -228,4 +228,2 @@ 'use strict' | ||
_tmpl.haveRaw = brackets.hasRaw | ||
_tmpl.hasExpr = brackets.hasExpr | ||
@@ -242,9 +240,17 @@ | ||
if (_tmpl.errorHandler) { | ||
err.riotData = { | ||
tagName: ctx && ctx.root && ctx.root.tagName, | ||
_riot_id: ctx && ctx._riot_id //eslint-disable-line camelcase | ||
} | ||
err.riotData = { | ||
tagName: ctx && ctx.root && ctx.root.tagName, | ||
_riot_id: ctx && ctx._riot_id //eslint-disable-line camelcase | ||
if (_tmpl.errorHandler) _tmpl.errorHandler(err) | ||
if ( | ||
typeof console !== 'undefined' && | ||
typeof console.error === 'function' | ||
) { | ||
if (err.riotData.tagName) { | ||
console.error('Riot template error thrown in the <%s> tag', err.riotData.tagName) | ||
} | ||
_tmpl.errorHandler(err) | ||
console.error(err) | ||
} | ||
@@ -422,3 +428,3 @@ } | ||
tmpl.version = brackets.version = 'v2.4.2' | ||
tmpl.version = brackets.version = 'v3.0.0-rc' | ||
@@ -425,0 +431,0 @@ /* istanbul ignore else */ |
{ | ||
"name": "riot-tmpl", | ||
"version": "2.4.2", | ||
"version": "3.0.0-rc", | ||
"description": "The riot template engine", | ||
@@ -5,0 +5,0 @@ "main": "dist/tmpl.js", |
@@ -62,11 +62,2 @@ /** | ||
/** | ||
* Checks if the expression or template is marked for to output raw HTML text. | ||
* | ||
* @param {string } expr - Expression to search | ||
* @returns {boolean} `true` if the expression is for raw html. | ||
* @function | ||
*/ | ||
_tmpl.haveRaw = brackets.hasRaw | ||
/** | ||
* Checks for an expression within a string, using the current brackets. | ||
@@ -120,4 +111,4 @@ * | ||
/** | ||
* Output an error message through the `_tmpl.errorHandler` function. | ||
* | ||
* Output an error message through the `_tmpl.errorHandler` function and | ||
* the console object. | ||
* @param {Error} err - The Error instance generated by the exception | ||
@@ -128,10 +119,19 @@ * @param {object} ctx - The context | ||
function _logErr (err, ctx) { | ||
// add some data to the Error object | ||
err.riotData = { | ||
tagName: ctx && ctx.root && ctx.root.tagName, | ||
_riot_id: ctx && ctx._riot_id //eslint-disable-line camelcase | ||
} | ||
if (_tmpl.errorHandler) { | ||
// add some data to the Error object | ||
err.riotData = { | ||
tagName: ctx && ctx.root && ctx.root.tagName, | ||
_riot_id: ctx && ctx._riot_id //eslint-disable-line camelcase | ||
// user error handler | ||
if (_tmpl.errorHandler) _tmpl.errorHandler(err) | ||
if ( | ||
typeof console !== 'undefined' && | ||
typeof console.error === 'function' | ||
) { | ||
if (err.riotData.tagName) { | ||
console.error('Riot template error thrown in the <%s> tag', err.riotData.tagName) | ||
} | ||
_tmpl.errorHandler(err) | ||
console.error(err) | ||
} | ||
@@ -138,0 +138,0 @@ } |
@@ -26,3 +26,3 @@ module.exports = function (config) { | ||
'../node_modules/expect.js/index.js', | ||
'../dist/riot.tmpl.js', | ||
'../dist/tmpl.js', | ||
'specs/core.specs.js', | ||
@@ -38,3 +38,3 @@ 'specs/brackets.specs.js' | ||
preprocessors: { | ||
'../dist/riot.tmpl.js': ['coverage'] | ||
'../dist/tmpl.js': ['coverage'] | ||
}, | ||
@@ -41,0 +41,0 @@ coverageReporter: { |
@@ -21,3 +21,4 @@ /*eslint camelcase: 0, max-len: 0 */ | ||
//var RAW_FLAG = '=' | ||
// avoid to output the console errors | ||
console.error = function () { /* noop */ } // eslint-disable-line | ||
@@ -505,18 +506,2 @@ // send 1 or 2 in 'err' to enable internal information | ||
}) | ||
//it('tmpl.haveRaw: test for raw html flag in a template (v2.3.14)', function () { | ||
// expect(tmpl.haveRaw('{' + RAW_FLAG + ' "<br>" }')).to.be(true) | ||
// expect(tmpl.haveRaw('{ ' + RAW_FLAG + ' "<br>" }')).to.be(false) | ||
// expect(tmpl.haveRaw('\\{= "<br>" } ')).to.be(false) | ||
// expect(tmpl.haveRaw(' {' + RAW_FLAG + ' "<br>" }')).to.be(true) | ||
// expect(tmpl.haveRaw(' { ' + RAW_FLAG + ' "<br>" }')).to.be(false) | ||
// expect(tmpl.haveRaw(' \\{= "<br>" } ')).to.be(false) | ||
//}) | ||
//it('the raw html is removed before evaluation (v2.3.14)', function () { | ||
// expect(render('{' + RAW_FLAG + ' "<br>" }')).to.be('<br>') | ||
// expect(render(' {' + RAW_FLAG + ' "<br>" }')).to.be(' <br>') | ||
// expect(render('{' + RAW_FLAG + ' "<" + str + ">" }')).to.be('<x>') | ||
//}) | ||
}) | ||
@@ -523,0 +508,0 @@ |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
357230
24
8979
1