component / reactive

Tiny reactive template engine
382 stars 48 forks source link

Thoughts on {{ }} vs { } #125

Closed defunctzombie closed 10 years ago

defunctzombie commented 10 years ago

I think {{ }} is better because it allows for blocks of code { } in the template body without having to escape them. Less things conflict with {{ }} versus { } (which is why most other template engines use the double {{ }}. It would be a breaking change, unless made an option (which we can easily do now).

There was a PR earlier about this and I would like to revisit the idea.

trevorgerhardt commented 10 years ago

+1

vendethiel commented 10 years ago

+1 to {{ }} or #{}

jcspencer commented 10 years ago

:+1:

jonathanong commented 10 years ago

{{}} all the way. {} is too difficult to read within templates imo

lvivier commented 10 years ago

I'm fine with {}, but +1 for {{}} over #{}, we generate lots of reactive templates with jade.

lancejpollard commented 10 years ago

I'd recommend against putting blocks of code that have curly brackets in the templates, that makes it tough to read. But simple expressions would be nice.

In terms of maximum optimization, the {} cuts out some extra characters. But it also (seems to) mean you couldn't allow for having raw JSON in the templates down the road if that was desired (but also not recommended because it seems like an anti-pattern, it seems the interpolated expressions should at least adhere to conventions that minimize the work the parser has to do).

Flex's MXML used {} and that was easy to read and never caused any limitations.

The {{}} is widely adopted, but it's also verbose.

@defunctzombie I have never run into the case you're describing, of having to escape something in an expression. What are some cases you're thinking of?

I don't really have a preference, more used to {{}} but feel like {} would be nice to use as well because it's simpler.

defunctzombie commented 10 years ago

I believe if you try to use the following as a reactive template it will fail:

<div>{name}</div>
<code>function() { }</code>

Obviously a trivial example but the idea is that { } is syntactically more common then {{ }}

lancejpollard commented 10 years ago

Ah, makes sense!

chemzqm commented 10 years ago

{{ }} +1 as it's easier to understand.

elidupuis commented 10 years ago

+1 for double-stash.

pakastin commented 10 years ago

+1

tegeek commented 10 years ago

+1

hallas commented 10 years ago

+1

defunctzombie commented 10 years ago

Work on this is being done in the next branch. Install and test with that if you want {{ }}