add allowReturnOutsideFunction to util.parse and make nodes optional in util.template

This commit is contained in:
Sebastian McKenzie
2014-11-10 08:16:22 +11:00
parent 3a3ad4775b
commit e0d3e18865

View File

@@ -111,6 +111,11 @@ exports.template = function (name, nodes, keepExpression) {
var template = exports.templates[name];
if (!template) throw new ReferenceError("unknown template " + name);
if (nodes === true) {
keepExpression = true;
nodes = null;
}
template = _.cloneDeep(template);
var inherits = false;
@@ -192,13 +197,14 @@ exports.parse = function (opts, code, callback) {
var tokens = [];
var ast = acorn.parse(code, {
preserveParens: true,
ecmaVersion: Infinity,
strictMode: true,
onComment: comments,
locations: true,
onToken: tokens,
ranges: true
allowReturnOutsideFunction: true,
preserveParens: true,
ecmaVersion: Infinity,
strictMode: true,
onComment: comments,
locations: true,
onToken: tokens,
ranges: true
});
estraverse.attachComments(ast, comments, tokens);