mustache / spec

The Mustache spec.
MIT License
364 stars 71 forks source link

Please drop triple Mustache #70

Closed bebna closed 3 years ago

bebna commented 11 years ago
  {{{unescaped}}}
groue commented 11 years ago

Hi, thanks for your contribution.

The triple mustache syntax is an "outsider" by requiring a specific symbol at the start and end of the tag.

Lazy developers can code applications, but should not code libraries : the only important metric is the users' convenience, not the developer's one. I'm afraid most users use triple mustache instead of the ampersand version (punctuation is creepy, nobody likes remembering another one).

Functionality is already given by Ampersand

So what?

It isn't defined how it should work with custom delimiters

We're listening to your proposal.

groue commented 11 years ago

Cool, you're coding Mustache in C https://github.com/bebna/cmustache !

That's great. Remember your convenience is the least important point. Think about providing a convenient API.

groue commented 11 years ago

A good reading: http://mattgemmell.com/2012/05/24/api-design/

bebna commented 11 years ago

Lazy developers

It just bothers me, it will be implemented in cmustache.

It isn't defined how it should work with custom delimiters

We're listening to your proposal.

It just needs a rewritten or extended description, so that it is clear that the double mustaches on the outside can be replaced by the custom delimiters. Like so:

{{=<% %>=}}<%{unescaped}%>

Thanks for the fast response, the shout out and link.

groue commented 11 years ago

Youre welcome.

Here is the comment in my own code, regarding the fate of triple mustache when delimiters are changed:

https://github.com/groue/GRMustache/blob/v6.7.4/src/classes/GRMustacheParser.m#L116

Mustache spec does not say that what happens to triple mustache tags when delimiters are not {{ and }}. It just says to use the & tag prefix: {{{ a }}} <=> {{& a }}.

We interpret this as a complete removal of triple mustache tags when delimiters are not {{ and }}

groue commented 11 years ago

About the triple mustache when delimiters are not {{ and }}, see also my answer to this issue: https://github.com/groue/GRMustache/issues/30

samwyse commented 11 years ago

bebna commented:

•The triple mustache syntax is an "outsider" by requiring a specific symbol at the start and end of the tag.

Not quite true, the syntax for changing delimiters works the same way. Look at {{=<% %>=}} in your own example, you need the '=' at both ends.

It just needs a rewritten or extended description, so that it is clear that the double mustaches on the outside can be replaced by the custom delimiters. Like so:

{{=<% %>=}}<%{unescaped}%>

For what it's worth, that's the same approach I'm taking. My parser alternately scans for opening and closing delimiters, and for an opening delimiter, looks at the next character to decide what to do. For both '{' and '=', the scanner temporarily changes the closing delimiter to have a leading '}' or '=', respectively. Since the closing '=' continues to be required when delimiters change, I thought that '{' should work the same.

bobthecow commented 10 years ago

Mustache.php takes the same approach. Both <%{ foo }%> and <%& foo %> are valid, and uneven braces (e.g. {{{ foo }}) throw a parse exception whether they're curly or custom delimiters.

For both '{' and '=', the scanner temporarily changes the closing delimiter to have a leading '}' or '=', respectively.

That's an interesting approach, and might be a cleaner way to do it than what Mustache.php does :P