Reputation: 4045
I'm puzzled by this notation that did spread a lot after the first templating engine using it became successful. The notation is {{bla}}
Does anyone know the practical reason for having two sets of {}? I think it reads very poorly; The deprecated JQuery one made more sense ( ${bla} )
Upvotes: 2
Views: 228
Reputation: 4064
How come Distal works without needing any escape characters like {{}}? http://code.google.com/p/distal
Upvotes: -1
Reputation: 669
It's because it's not an often used combination of characters.
Template parsing is all about regular expressions and then turning the text into tokens, and then compiling those tokens into another language (like HTML).
Since we don't want to catch common characters in our regular expressions, we need to use those that aren't common combos of characters.
it's the same reason PHP uses <?php ?>
and ASP uses <% %>
.
Like in Twig, the lexer looks for {{ }}
and {% %}
to find Twig commands. If I had to use { }
, every time I had that anywhere in the template (not just HTML markup), I'd have to escape it. And since the point of a template language is ease of use, The language needs to make its "tokens" as distinguishable as possible.
Upvotes: 2