Skip to content
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

Creating attributes with @html.raw #112

Open
sant123 opened this issue Oct 25, 2016 · 3 comments
Open

Creating attributes with @html.raw #112

sant123 opened this issue Oct 25, 2016 · 3 comments
Labels

Comments

@sant123
Copy link

sant123 commented Oct 25, 2016

Hi, I want to make some attribute according to condition.

@{ var homepageClass = model.homepage ? ' class="homepage"' : ""; }
<body@html.raw(homepageClass)>
</body>

Generated code:

<body class="homepage">
</body class="homepage">

¿Is this an expected behavior?

@kirbysayshi kirbysayshi added the bug label May 8, 2017
@kirbysayshi
Copy link
Owner

This is definitely a bug, but there is a workaround. The problem is that vash is interpreting the html tag name as, literally, body@html.raw(homepageClass).

Workaround: Put a space in there! => <body @html.raw(homepageClass)> Of course, you'll need to change your ternary to not include the space as well.

@kirbysayshi
Copy link
Owner

kirbysayshi commented May 8, 2017

Found another bug related: <body @model.what class=""></body> fails to compile due to the parser not bailing on the space between .what and class. Workaround: enclose model.what in parens: <body @(model.what) class=""></body>

@sant123
Copy link
Author

sant123 commented May 9, 2017

Thank you @kirbysayshi for answering, long time but better than never 😄 I used this option <body @html.raw(homepageClass)> for working around. I really expect this gets fixed soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants