3

There is a phtml template file in one of the third party Magento 2 extension which has triple curly braces {{{ }}} in it.
When is this notation used, What does it represent?

3

Magento uses option "noEscape" set to true when compiling the template if you want to use {{ }} when {{{ }}} are required to successfully replace the templates.

/vendor/magento/magento2-base/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Address/Renderer.php

Above is the reference where Magento V 2.2.4 uses Render output from Address fixture according to data format type using variables.

  • Handlebars HTML-escapes values returned by a {{expression}}.
  • If you don't want Handlebars to escape a value, use the "triple-stash", {{{.
2
  • 1
    Good explanation. +1 Mar 13 '19 at 5:20
  • Thanks, Shoaib Munir :) Mar 13 '19 at 5:21
2

Handlebars HTML-escapes values returned by a {{expression}}. If you don't want Handlebars to escape a value, use the "triple-stash", {{{.

<div class="entry">
  <h1>{{title}}</h1>
  <div class="body">
    {{{body}}}
  </div>
</div>

with this context:

{
  title: "All about <p> Tags",
  body: "<p>This is a post about &lt;p&gt; tags</p>"
}

results in:

<div class="entry">
  <h1>All About &lt;p&gt; Tags</h1>
  <div class="body">
    <p>This is a post about &lt;p&gt; tags</p>
  </div>
</div>

Reference: https://handlebarsjs.com/guide/#html-escaping

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.