Giter VIP home page Giter VIP logo

Comments (5)

chriskrycho avatar chriskrycho commented on June 8, 2024 5

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>

from rfcs.

runspired avatar runspired commented on June 8, 2024 2

+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.

from rfcs.

sandstrom avatar sandstrom commented on June 8, 2024

I think this is something that Ember has inherited from Handlebars:
https://handlebarsjs.com/guide/builtin-helpers.html#if

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.

from rfcs.

chriskrycho avatar chriskrycho commented on June 8, 2024

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.

from rfcs.

chancancode avatar chancancode commented on June 8, 2024

I don't think there is anything intrinsically very wrong with this that requires rectification.

FWIW {{else}} isn't the only one, there are also {{debugger}}, {{yield}}, etc, which would not be "fixed" by the proposed syntax.

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. return, debugger, break, continue, etc, all would have been an identifier if you change any one letter, or if you want to look at expression position, there are yield, arguments, null, false, etc, which would could totally use in places that would have been a variable reference. For example, console.log(yield) and console.log(foo) are syntactically indistinguishable, just that one happens to be a keyword. There are even import.meta, new.target... for some recent additions.

IMO if your syntax highlighting is working it shouldn't be particularly surprising or unexpected, especially since the <template> tag now shares the JS scope and you would never be able to use any of the JS keywords as template bindings anyway. I think there are many reasons to revisit the syntax, but this alone/by itself isn't a strong case.

As far single vs double curlies, there is a couple of tradeoffs, and personally I think on balance {{ is right. For instance if switching to single curlies would mean that anytime you use a { in the HTML content you would have to escape it, so stuff you copy and paste from HTML examples are now less likely to Just Work™ (which, historically has been a strong guiding principle for Ember in this space). Also, now that we are embedded in the JavaScript space, I personally find that highlighting/viewing {{ as a single special token has value, because it is very distinct from what { usually means in JS, especially if we ever want to embed some object literal-like syntax or subset of JavaScript syntax inside these positions.

Nothing that can't be overcome, but I don't see a strong reason to change them. Personally I probably would still have picked {{ if designing a new language from scratch today. Or maybe ${ ... } 🤷🏼‍♂️

from rfcs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.