-
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
Not able to use semicolons for proper JavaScript in blocks #27
Comments
Could you clarify what you mean by "broken"? You mean rely on ASI as opposed to manual semicolon insertion? It was a trade off I made to make the parser/compiler slightly less complex. Perhaps I should revisit this. Are you running into a tooling issue, aside from personal compulsions :) ? |
Hm, okay, perhaps broken was the wrong word. Let's say it like this: If I insert the (missing) semicolon, it is not ignored, but Vash sends it as normal output to the HTML. So it is not possible to use final semicolons (or I am missing something here). And, no it's not a tooling issue, just personal style ;-) |
No, you're not missing anything, unfortunately that's a limitation in vash. It's very difficult for vash to know the difference between I could put in an exception/hack specifically for blocks containing callbacks, but I've resisted since it would break consistency (aside from within a block, all semicolons are treated as content). |
I've been thinking about this some more, and I think it's actually impossible for vash to know when a trailing semicolon is meant to be code or content. However, you can force the semicolons to be parsed as code by wrapping the layout calls in an anonymous code "block": @{
html.extend('layout', function (model) {
@html.block('content', function (model) {
<p>Hallo Welt!</p>
});
});
} Going to close this for now, as the case of |
Supposed I have the following file
index.vash
:Then the code is "broken" due to missing semicolons at the end of the two lines containing the
})
characters. But if I add them I won't get the result I'd like to, as they are sent to the client instead.How to fix this?
The text was updated successfully, but these errors were encountered: