-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
{{else}} should render a value rather than be a control-flow keyword. #917
Comments
This is a good thing to consider changing, though note that keywords and control structures in most languages are allowed to have their own syntactic forms. I would also suggest that the time to make that change would be in a broader syntactic reform, i.e. a switch to a single-curly-based form that is similar to Svelte's templates: <template lang='sveltish'>
{#if condition}
{:else if otherCondition}
{:else}
{/if}
</template> |
+1 for broader reform. Been thinking of proposing this since it actually wouldn't be hard to implement in the parser and could be done initially as an external optional offering. Double curlies don't feel necessary anymore to me. |
I think this is something that Ember has inherited from Handlebars: I don't know how far Ember templates has deviated from Handlebars, so maybe going further away isn't a problem. But one thing to consider is that Handlebars tooling (linting, syntax highlighters, etc) mostly work with Ember, which is nice. With a custom template language, Ember would have to maintain that stuff themselves, which is more work. |
That's correct; technically Glimmer templates are still Handlebars templates. They've diverged substantially, but by addition rather than by change overall. The first pass of the parser is the JS Handlebars parser… but then we have to do more work to get to what we have today. That's a real and genuine concern, regardless, especially as regards syntax highlighting. |
I don't think there is anything intrinsically very wrong with this that requires rectification. FWIW But as @chriskrycho said there isn't anything abnormal about this. In JavaScript you could say the same about many of the keywords that would otherwise be some other kind of statement/expression in the same position if spelled differently. IMO if your syntax highlighting is working it shouldn't be particularly surprising or unexpected, especially since the As far single vs double curlies, there is a couple of tradeoffs, and personally I think on balance Nothing that can't be overcome, but I don't see a strong reason to change them. Personally I probably would still have picked |
One thing I noticed as I am both going through the Svelte tutorial again as well as writing a similar one for Ember /
<template>
, is that{{else}}
is is syntactically incoherent.Everywhere else, we use
{{ identifier }}
to render a value except for{{else}}
.For consistency, I think we should fix that.
Svelte uses a "continuation" syntax to denote that a block is continuing.
So for us, that would look like this:
which has 0 ambiguity with value-rendering.
The text was updated successfully, but these errors were encountered: