We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how to suspend template parsing in Volt

In rare cases it is useful or necessary to disable parsing of Volt tags. For instance if you want to show the literal string "{{ endblock }}" which of course is a rare case. However, if you want to write some javascript code inside your template you might encounter situations where you might have to write character sequences that resemble Volt directives. This is particularly true when writing regular expressions in Javascript. Smarty provides a very useful tag {literal}{/literal} that suspend all Smarty tag parsing in between. So, how should I solve this in Volt?



5.1k
edited Dec '14

As a dirty fix you can use: {{ "{{ endblock }}" }}

There is open issue about this: https://github.com/phalcon/cphalcon/issues/1253