mustache / mustache.github.com

The {{official}} website
http://mustache.github.io/
Other
2.33k stars 293 forks source link

Specify a character for escaped substitution #86

Closed jobol closed 11 months ago

jobol commented 7 years ago

When the name of the variable starts with a character that is normally interpreted within mustache templating (i.e. "#^/{&!>:") it should be possible to use an escape character. This commit propose to use colon (:) as first character to escape the first character of variable name in the variable substitution with escaping. Writing {{:NAME}} is equivalent to writing {{NAME}} even when NAME begins with a special character.

It is interesting to see that it specify an optional character for variable substitution with escaping and not only an escaping character.

jobol commented 7 years ago

I propose the character : but I agree that any character is possible.

I had in fact the issue with a name starting with #

jobol commented 7 years ago

There is a good spec for JSON pointers: https://tools.ietf.org/html/rfc6901

So having a special character (like ':' ) for explicit value substitution would allow to write {{:/root/4}} that uses the json pointer

jobol commented 6 years ago

Maybe the character = is better

jgonggrijp commented 11 months ago

Sorry to keep you hanging for so long and then brutally closing the pull request. As I detailed in https://github.com/mustache/spec/discussions/174#discussioncomment-7555861, the spec should be updated before the manual, and the source file for the manual is also in a different repository.

(In my defense, I was not yet involved here when you opened the pull request.)