Receiving UnmatchedCharacterError for simple vash helper
Closed this issue · 4 comments
steebchen commented
@{
vash.helpers.earnings = function (e) {
e = e || 0;
return Math.round(e * 100) / 100;
};
}
gives me this error:
UnmatchedCharacterError: Unmatched FORWARD_SLASH at line 4, character 24. Value: /
+PROGRAM
| +BLOCK
| | [NEWLINE (2,38): ]
| | [IDENTIFIER (3,0): e]
| | [WHITESPACE (3,1): ]
| | [ASSIGN_OPERATOR (3,2): =]
| | [WHITESPACE (3,3): ]
| | [IDENTIFIER (3,4): e]
| | [WHITESPACE (3,5): ]
| | [LOGICAL (3,6): ||]
| | [WHITESPACE (3,8): ]
| | [NUMERIC_CONTENT (3,9): 0]
| | [CONTENT (3,10): ;]
| | [NEWLINE (3,11): ]
| | [IDENTIFIER (4,0): e]
| | [WHITESPACE (4,1): ]
| | [ASSIGN_OPERATOR (4,2): =]
| | [WHITESPACE (4,3): ]
| | [IDENTIFIER (4,4): Math]
| | [PERIOD (4,8): .]
| | [IDENTIFIER (4,9): round]
| | [PAREN_OPEN (4,14): (]
| | +BLOCK
| | | [IDENTIFIER (4,15): e]
| | | [WHITESPACE (4,16): ]
| | | [OPERATOR (4,17): *]
| | | [WHITESPACE (4,18): ]
| | | [NUMERIC_CONTENT (4,19): 100]
| | -BLOCK
| | [PAREN_CLOSE (4,22): )]
| | [WHITESPACE (4,23): ]
| -BLOCK
-PROGRAM
at Object.VParser.advanceUntilMatched (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:629:44)
at Object.VParser.handleBLK (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:861:23)
at Object.VParser.parse (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:538:10)
at Object.VParser.subParse (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:659:13)
at Object.VParser.handleBLK (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:891:10)
at Object.VParser.parse (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:538:10)
at Object.VParser.subParse (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:659:13)
at Object.VParser.handleBLK (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:891:10)
at Object.VParser.parse (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:538:10)
at Object.compile (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:1319:4)
at Object.vash.loadFile (/home/luca/Documents/projects/nodejsapp/node_modules/vash/build/vash.js:2068:12)
at View.vash.renderFile [as engine]
[...]
When removing / 100
it's working. I'm using v0.11.1 from NPM.
kirbysayshi commented
@steebchen sorry for the delay on this, a fix is inbound, hopefully (regex parsing is... tricky). Somewhat related, the output you pasted above is definitely not from vash 0.11, more like 0.7.x. Could you ensure you update your vash dependency as well?
kirbysayshi commented
@steebchen ok, should be fixed in v0.11.2! Please reopen if it's not, and thanks!
steebchen commented
I am using vash@0.12.1 but this is still throwing an error.
While this is working
function round(i) {
var val = Math.round(i * roundDiff)
return val / roundDiff
}
the following
function round(i) {
return Math.round(i * roundDiff) / roundDiff
}
throws this:
SyntaxError: Problem while rendering template at line 8, character 0.
Original message: Problem while compiling template at line 0, character 0.
Original message: Unexpected token ILLEGAL.
Context:
[thousand lines of code]
.
at Function (native)
at Object.runtime.link ([cut]/node_modules/vash/runtime.js:308:26)
at Object.exports.compile ([cut]/node_modules/vash/index.js:73:21)
at Object.vash.loadFile ([cut]/node_modules/vash/lib/helpers/layout.js:66:14)
at Helpers.helpers.include ([cut]/node_modules/vash/lib/helpers/layout.js:230:8)
at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:91:33)
at Helpers.helpers.block ([cut]/node_modules/vash/lib/helpers/layout.js:253:5)
at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:61:33)
at [cut]/node_modules/vash/lib/helpers/layout.js:197:5
at Object.vash.loadFile ([cut]/node_modules/vash/lib/helpers/layout.js:68:11)
at Helpers.helpers.extend ([cut]/node_modules/vash/lib/helpers/layout.js:188:8)
at eval (eval at <anonymous> ([cut]/node_modules/vash/runtime.js:308:26), <anonymous>:10:33)
at linked ([cut]/node_modules/vash/runtime.js:348:14)
at [cut]/node_modules/vash/lib/helpers/layout.js:80:22
at Object.vash.loadFile ([cut]/node_modules/vash/lib/helpers/layout.js:68:11)
at View.vash.renderFile.vash.__express [as engine] ([cut]/node_modules/vash/lib/helpers/layout.js:76:8)
at View.render ([cut]/node_modules/express/lib/view.js:126:8)
at tryRender ([cut]/node_modules/express/lib/application.js:639:10)
at EventEmitter.render ([cut]/node_modules/express/lib/application.js:591:3)
at ServerResponse.render ([cut]/node_modules/express/lib/response.js:960:7)
at [cut]/app.js:101:6
at Layer.handle [as handle_request] ([cut]/node_modules/express/lib/router/layer.js:95:5)
at next ([cut]/node_modules/express/lib/router/route.js:131:13)
at [cut]/app.js:96:3
at [cut]/node_modules/mongoose/lib/query.js:2257:18
at process._tickDomainCallback (node.js:438:9)
kirbysayshi commented
should be fixed in 0.12.2!