pull out the input processing out of the parser class and a few small improvements - the no js option now applies to all js, including that within quotes. The Javascript node now also returns the right index.

This commit is contained in:
Luke Page
2014-08-25 12:19:04 +01:00
parent f3c323810c
commit 41732cc60b
6 changed files with 558 additions and 509 deletions

View File

@@ -10,6 +10,11 @@ jsEvalNode.prototype.evaluateJavaScript = function (expression, env) {
that = this,
context = {};
if (env.javascriptEnabled !== undefined && !env.javascriptEnabled) {
throw { message: "You are using JavaScript, which has been disabled." ,
index: this.index };
}
expression = expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
return that.jsify(new(Variable)('@' + name, that.index).eval(env));
});