riot-compiler
Advanced tools
Comparing version 2.5.1 to 2.5.2
# Compiler Changes | ||
### v2.5.2 | ||
- Fix #72: `undefined` is not a function when evaluating `parsers._req`. | ||
- Updated node versions for travis, including v5.x | ||
### v2.4.1 | ||
@@ -4,0 +8,0 @@ |
/** | ||
* Compiler for riot custom tags | ||
* @version v2.5.1 | ||
* @version v2.5.2 | ||
*/ | ||
@@ -26,10 +26,23 @@ | ||
*/ | ||
var parsers = (function () { | ||
var parsers = (function (win) { | ||
var _p = {} | ||
function _r (name) { | ||
var parser = win[name] | ||
if (parser) return parser | ||
throw new Error('Parser "' + name + '" not loaded.') | ||
} | ||
function _req (name) { | ||
var parser = window[name] | ||
var parts = name.split('.') | ||
if (parts.length !== 2) throw new Error('Bad format for parsers._req') | ||
var parser = _p[parts[0]][parts[1]] | ||
if (parser) return parser | ||
throw new Error(name + ' parser not found.') | ||
throw new Error('Parser "' + name + '" not found.') | ||
} | ||
@@ -55,66 +68,61 @@ | ||
}, opts) | ||
return _req(compilerName).render(html, opts) | ||
return _r(compilerName).render(html, opts) | ||
} | ||
var _p = { | ||
html: { | ||
jade: function (html, opts, url) { | ||
/* eslint-disable */ | ||
console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in riot@3.0.0!') | ||
/* eslint-enable */ | ||
return renderPug('jade', html, opts, url) | ||
}, | ||
pug: function (html, opts, url) { | ||
return renderPug('pug', html, opts, url) | ||
} | ||
_p.html = { | ||
jade: function (html, opts, url) { | ||
/* eslint-disable */ | ||
console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in riot@3.0.0!') | ||
/* eslint-enable */ | ||
return renderPug('jade', html, opts, url) | ||
}, | ||
pug: function (html, opts, url) { | ||
return renderPug('pug', html, opts, url) | ||
} | ||
} | ||
_p.css = { | ||
less: function (tag, css, opts, url) { | ||
var ret | ||
css: { | ||
less: function (tag, css, opts, url) { | ||
var ret | ||
opts = extend({ | ||
sync: true, | ||
syncImport: true, | ||
filename: url | ||
}, opts) | ||
_req('less').render(css, opts, function (err, result) { | ||
// istanbul ignore next | ||
if (err) throw err | ||
ret = result.css | ||
}) | ||
return ret | ||
} | ||
opts = extend({ | ||
sync: true, | ||
syncImport: true, | ||
filename: url | ||
}, opts) | ||
_r('less').render(css, opts, function (err, result) { | ||
// istanbul ignore next | ||
if (err) throw err | ||
ret = result.css | ||
}) | ||
return ret | ||
} | ||
} | ||
_p.js = { | ||
es6: function (js, opts) { | ||
opts = extend({ | ||
blacklist: ['useStrict', 'strict', 'react'], | ||
sourceMaps: false, | ||
comments: false | ||
}, opts) | ||
return _r('babel').transform(js, opts).code | ||
}, | ||
js: { | ||
es6: function (js, opts) { | ||
opts = extend({ | ||
blacklist: ['useStrict', 'strict', 'react'], | ||
sourceMaps: false, | ||
comments: false | ||
}, opts) | ||
return _req('babel').transform(js, opts).code | ||
}, | ||
babel: function (js, opts, url) { | ||
return _req('babel').transform(js, extend({ filename: url }, opts)).code | ||
}, | ||
coffee: function (js, opts) { | ||
return _req('CoffeeScript').compile(js, extend({ bare: true }, opts)) | ||
}, | ||
livescript: function (js, opts) { | ||
return _req('livescript').compile(js, extend({ bare: true, header: false }, opts)) | ||
}, | ||
typescript: function (js, opts) { | ||
return _req('typescript')(js, opts) | ||
}, | ||
none: function (js) { | ||
return js | ||
} | ||
babel: function (js, opts, url) { | ||
return _r('babel').transform(js, extend({ filename: url }, opts)).code | ||
}, | ||
coffee: function (js, opts) { | ||
return _r('CoffeeScript').compile(js, extend({ bare: true }, opts)) | ||
}, | ||
livescript: function (js, opts) { | ||
return _r('livescript').compile(js, extend({ bare: true, header: false }, opts)) | ||
}, | ||
typescript: function (js, opts) { | ||
return _r('typescript')(js, opts) | ||
}, | ||
none: function (js) { | ||
return js | ||
} | ||
} | ||
_p.js.javascript = _p.js.none | ||
_p.js.coffeescript = _p.js.coffee | ||
_p._req = _req | ||
_p.utils = { | ||
@@ -126,3 +134,3 @@ extend: extend | ||
})() | ||
})(window || global) | ||
@@ -715,3 +723,3 @@ /** | ||
var version = 'v2.5.1' | ||
var version = 'v2.5.2' | ||
@@ -718,0 +726,0 @@ export default { |
@@ -20,10 +20,23 @@ | ||
*/ | ||
var parsers = (function () { | ||
var parsers = (function (win) { | ||
var _p = {} | ||
function _r (name) { | ||
var parser = win[name] | ||
if (parser) return parser | ||
throw new Error('Parser "' + name + '" not loaded.') | ||
} | ||
function _req (name) { | ||
var parser = window[name] | ||
var parts = name.split('.') | ||
if (parts.length !== 2) throw new Error('Bad format for parsers._req') | ||
var parser = _p[parts[0]][parts[1]] | ||
if (parser) return parser | ||
throw new Error(name + ' parser not found.') | ||
throw new Error('Parser "' + name + '" not found.') | ||
} | ||
@@ -49,66 +62,61 @@ | ||
}, opts) | ||
return _req(compilerName).render(html, opts) | ||
return _r(compilerName).render(html, opts) | ||
} | ||
var _p = { | ||
html: { | ||
jade: function (html, opts, url) { | ||
/* eslint-disable */ | ||
console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in riot@3.0.0!') | ||
/* eslint-enable */ | ||
return renderPug('jade', html, opts, url) | ||
}, | ||
pug: function (html, opts, url) { | ||
return renderPug('pug', html, opts, url) | ||
} | ||
_p.html = { | ||
jade: function (html, opts, url) { | ||
/* eslint-disable */ | ||
console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in riot@3.0.0!') | ||
/* eslint-enable */ | ||
return renderPug('jade', html, opts, url) | ||
}, | ||
pug: function (html, opts, url) { | ||
return renderPug('pug', html, opts, url) | ||
} | ||
} | ||
_p.css = { | ||
less: function (tag, css, opts, url) { | ||
var ret | ||
css: { | ||
less: function (tag, css, opts, url) { | ||
var ret | ||
opts = extend({ | ||
sync: true, | ||
syncImport: true, | ||
filename: url | ||
}, opts) | ||
_req('less').render(css, opts, function (err, result) { | ||
// istanbul ignore next | ||
if (err) throw err | ||
ret = result.css | ||
}) | ||
return ret | ||
} | ||
opts = extend({ | ||
sync: true, | ||
syncImport: true, | ||
filename: url | ||
}, opts) | ||
_r('less').render(css, opts, function (err, result) { | ||
// istanbul ignore next | ||
if (err) throw err | ||
ret = result.css | ||
}) | ||
return ret | ||
} | ||
} | ||
_p.js = { | ||
es6: function (js, opts) { | ||
opts = extend({ | ||
blacklist: ['useStrict', 'strict', 'react'], | ||
sourceMaps: false, | ||
comments: false | ||
}, opts) | ||
return _r('babel').transform(js, opts).code | ||
}, | ||
js: { | ||
es6: function (js, opts) { | ||
opts = extend({ | ||
blacklist: ['useStrict', 'strict', 'react'], | ||
sourceMaps: false, | ||
comments: false | ||
}, opts) | ||
return _req('babel').transform(js, opts).code | ||
}, | ||
babel: function (js, opts, url) { | ||
return _req('babel').transform(js, extend({ filename: url }, opts)).code | ||
}, | ||
coffee: function (js, opts) { | ||
return _req('CoffeeScript').compile(js, extend({ bare: true }, opts)) | ||
}, | ||
livescript: function (js, opts) { | ||
return _req('livescript').compile(js, extend({ bare: true, header: false }, opts)) | ||
}, | ||
typescript: function (js, opts) { | ||
return _req('typescript')(js, opts) | ||
}, | ||
none: function (js) { | ||
return js | ||
} | ||
babel: function (js, opts, url) { | ||
return _r('babel').transform(js, extend({ filename: url }, opts)).code | ||
}, | ||
coffee: function (js, opts) { | ||
return _r('CoffeeScript').compile(js, extend({ bare: true }, opts)) | ||
}, | ||
livescript: function (js, opts) { | ||
return _r('livescript').compile(js, extend({ bare: true, header: false }, opts)) | ||
}, | ||
typescript: function (js, opts) { | ||
return _r('typescript')(js, opts) | ||
}, | ||
none: function (js) { | ||
return js | ||
} | ||
} | ||
_p.js.javascript = _p.js.none | ||
_p.js.coffeescript = _p.js.coffee | ||
_p._req = _req | ||
_p.utils = { | ||
@@ -120,3 +128,3 @@ extend: extend | ||
})() | ||
})(window || global) | ||
@@ -127,3 +135,3 @@ riot.parsers = parsers | ||
* Compiler for riot custom tags | ||
* @version v2.5.1 | ||
* @version v2.5.2 | ||
*/ | ||
@@ -719,3 +727,3 @@ var compile = (function () { | ||
js: compileJS, | ||
version: 'v2.5.1' | ||
version: 'v2.5.2' | ||
} | ||
@@ -722,0 +730,0 @@ return compile |
/** | ||
* The riot-compiler v2.5.1 | ||
* The riot-compiler v2.5.2 | ||
* | ||
* @module compiler | ||
* @version v2.5.1 | ||
* @version v2.5.2 | ||
* @license MIT | ||
@@ -1038,3 +1038,3 @@ * @copyright Muut Inc. + contributors | ||
parsers: parsers, | ||
version: 'v2.5.1' | ||
version: 'v2.5.2' | ||
} |
{ | ||
"name": "riot-compiler", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"description": "Compiler for riot .tag files", | ||
@@ -34,5 +34,5 @@ "main": "lib/compiler.js", | ||
"coveralls": "^2.11.9", | ||
"eslint": "^2.13.0", | ||
"eslint": "^2.13.1", | ||
"expect.js": "^0.3.1", | ||
"istanbul": "^0.4.3", | ||
"istanbul": "^0.4.4", | ||
"jspreproc": "^0.2.7", | ||
@@ -39,0 +39,0 @@ "mocha": "^2.5.3", |
@@ -8,4 +8,17 @@ //#if 0 | ||
*/ | ||
var parsers = (function () { | ||
var parsers = (function (win) { | ||
var _p = {} // parsers | ||
/* | ||
* Internal function to access a parser | ||
*/ | ||
function _r (name) { | ||
var parser = win[name] | ||
if (parser) return parser | ||
throw new Error('Parser "' + name + '" not loaded.') | ||
} | ||
/** | ||
@@ -15,11 +28,14 @@ * Returns a parser instance by its name, get the variable from the global object. | ||
* | ||
* @param {string} name - The parser's name, as registered in the parsers object | ||
* @returns {Function} - The parser instance, null if the parser is not found | ||
* @param {string} name - The parser's branch and name in dot notation | ||
* @returns {Function} The parser instance, null if the parser is not found. | ||
*/ | ||
function _req (name) { | ||
var parser = window[name] | ||
var parts = name.split('.') | ||
if (parts.length !== 2) throw new Error('Bad format for parsers._req') | ||
var parser = _p[parts[0]][parts[1]] | ||
if (parser) return parser | ||
throw new Error(name + ' parser not found.') | ||
throw new Error('Parser "' + name + '" not found.') | ||
} | ||
@@ -53,3 +69,3 @@ | ||
}, opts) | ||
return _req(compilerName).render(html, opts) | ||
return _r(compilerName).render(html, opts) | ||
} | ||
@@ -59,63 +75,58 @@ | ||
var _p = { | ||
html: { | ||
jade: function (html, opts, url) { | ||
/* eslint-disable */ | ||
console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in riot@3.0.0!') | ||
/* eslint-enable */ | ||
return renderPug('jade', html, opts, url) | ||
}, | ||
pug: function (html, opts, url) { | ||
return renderPug('pug', html, opts, url) | ||
} | ||
_p.html = { | ||
jade: function (html, opts, url) { | ||
/* eslint-disable */ | ||
console.log('DEPRECATION WARNING: jade was renamed "pug" - The jade parser will be removed in riot@3.0.0!') | ||
/* eslint-enable */ | ||
return renderPug('jade', html, opts, url) | ||
}, | ||
pug: function (html, opts, url) { | ||
return renderPug('pug', html, opts, url) | ||
} | ||
} | ||
_p.css = { | ||
less: function (tag, css, opts, url) { | ||
var ret | ||
css: { | ||
less: function (tag, css, opts, url) { | ||
var ret | ||
opts = extend({ | ||
sync: true, | ||
syncImport: true, | ||
filename: url | ||
}, opts) | ||
_req('less').render(css, opts, function (err, result) { | ||
// istanbul ignore next | ||
if (err) throw err | ||
ret = result.css | ||
}) | ||
return ret | ||
} | ||
opts = extend({ | ||
sync: true, | ||
syncImport: true, | ||
filename: url | ||
}, opts) | ||
_r('less').render(css, opts, function (err, result) { | ||
// istanbul ignore next | ||
if (err) throw err | ||
ret = result.css | ||
}) | ||
return ret | ||
} | ||
} | ||
_p.js = { | ||
es6: function (js, opts) { | ||
opts = extend({ | ||
blacklist: ['useStrict', 'strict', 'react'], | ||
sourceMaps: false, | ||
comments: false | ||
}, opts) | ||
return _r('babel').transform(js, opts).code | ||
}, | ||
js: { | ||
es6: function (js, opts) { | ||
opts = extend({ | ||
blacklist: ['useStrict', 'strict', 'react'], | ||
sourceMaps: false, | ||
comments: false | ||
}, opts) | ||
return _req('babel').transform(js, opts).code | ||
}, | ||
babel: function (js, opts, url) { | ||
return _req('babel').transform(js, extend({ filename: url }, opts)).code | ||
}, | ||
coffee: function (js, opts) { | ||
return _req('CoffeeScript').compile(js, extend({ bare: true }, opts)) | ||
}, | ||
livescript: function (js, opts) { | ||
return _req('livescript').compile(js, extend({ bare: true, header: false }, opts)) | ||
}, | ||
typescript: function (js, opts) { | ||
return _req('typescript')(js, opts) | ||
}, | ||
none: function (js) { | ||
return js | ||
} | ||
babel: function (js, opts, url) { | ||
return _r('babel').transform(js, extend({ filename: url }, opts)).code | ||
}, | ||
coffee: function (js, opts) { | ||
return _r('CoffeeScript').compile(js, extend({ bare: true }, opts)) | ||
}, | ||
livescript: function (js, opts) { | ||
return _r('livescript').compile(js, extend({ bare: true, header: false }, opts)) | ||
}, | ||
typescript: function (js, opts) { | ||
return _r('typescript')(js, opts) | ||
}, | ||
none: function (js) { | ||
return js | ||
} | ||
} | ||
_p.js.javascript = _p.js.none | ||
_p.js.coffeescript = _p.js.coffee // 4 the nostalgics | ||
_p._req = _req | ||
_p.utils = { | ||
@@ -127,2 +138,2 @@ extend: extend | ||
})() | ||
})(window || global) |
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
249384
5667