-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why I can't use variable into attribute? #21
Comments
This is code also doesn't work https://gist.github.com/gr1feel/5418016 |
I'm not sure I follow, those render just fine for me: $ echo '<a onclick="alert('@model.text1')">click me!</a> ' | ./node_modules/vash/bin/vash --json '{"debug": false}' --render '{ "text1": "hello" }'
<a onclick="alert(hello)">click me!</a> drewp@SpottedRadioFreeAir /tmp/vash-test$ node
> var vash = require('vash');
undefined
> var tpl = vash.compile("<a onclick=\"alert('@model.text1')\">click me!</a>")
undefined
> tpl({ text1: "hello" })
'<a onclick="alert(\'hello\')">click me!</a>' Could you provide more details as to what "fail" means in your case? |
Any other details you can provide? |
Hi, https://docs.google.com/file/d/0B0E2riyj_WiwVDBNMnpvTndBaFU/view |
Ok, thanks for the examples, they really help. The issue is that a There is another issue too in the same vein. The parentheses in (__vbuffer.push(html.escape(model.text2).toHtmlString());) A semicolon is not valid JS within the grouping parentheses, so this is actually not even compiling. The error reporting is giving you a false sense of where the error is happening because it's not actually at runtime, but rather at compile time. This is just bad reporting that I've been meaning to fix, and have opened an issue to keep track of it (#22). Your immediate solution: @html.block('content', function(model){
@* Remember that <text> tags are not rendered! *@
<text>
<br/>Text1: @model.text1
<br/>Text2: @model.text2
<br/>@model.child.xxx
<span>hi</span> (@model.text2)
</text>
}) There are others, like using @html.block('content', function(model){
@:<br/>Text1: @model.text1
@:<br/>Text2: @model.text2
<br/>@model.child.xxx
@:<span>hi</span> (@model.text2)
}) |
Hi kirbysayshi ,
I have a little problem. Why I can't use variable into attribute?
For example, this code always fails https://gist.github.com/gr1feel/5418010
The text was updated successfully, but these errors were encountered: