zordius / lightncandy

An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ),
https://zordius.github.io/HandlebarsCookbook/
MIT License
610 stars 76 forks source link

display }} in template #290

Open lucian-dragomir opened 6 years ago

lucian-dragomir commented 6 years ago

Hi, if you want to display {{ you can use this: {{#with "{{"}}{{.}}{{/with}} as specified in "Suggested Handlebars Template Practices".

I'm trying to display }} and if i add {{#with "}}"}}{{.}}{{/with}} the render function crashes.

I found an workaround ... to display one } at a time by using {{#with "}"}}{{.}}{{/with}} but it should work with }}.

Thx, Lucian

zordius commented 6 years ago

Thank you for your idea! Here are some more detail:

  1. If you want to display atomic }} , you can just use it without any trick. EX: {{foo}} }}
  2. If you want to display } just after any handlebars token, you can use this: {{#with "}"}}{{.}}{{/with}} . EX: {{foo}}{{#with "}"}}{{.}}{{/with}}
  3. If you want to display atomic { , you can just use it without any trick. EX: { and {{foo}}.
  4. If you want to display atomic {{ and there is no any handlebars token after it, you can just use it without any trick. EX: {{foo}} {{
  5. If you want to display {{ and there is handlebars token after it, you should use {{#with "{{"}}{{.}}{{/with}}. EX: {{#with "{{"}}{{.}}{{/with}}{{foo}}{{#with "{{"}}{{.}}{{/with}}