twigbolt-cmstwig-filter

Output from field of type HTML prints tags verbatim (BOLT-CMS / Twig)


In Bolt CMS, I have a field defined like so:

contenttypes.yaml

details:    # thats my new content type
  name: (...)
  (...)
  fields:
    (...)
    contentblocks:
      type: block
      label: Content
      fields:
        freetext:
          label: Formatted Text
          fields:
            content:
              type: html
  (...)

However, now when i display this in my template with ...

{% setcontent nameAddr = 'data/name-addr' %}
{% for group in nameAddr.contentblocks %}
  {% if group.block == 'freetext' %}
    {{group.content}}
  {% endif %}
{% endfor %}

... I get output like this in the page (via view-source):

<p>a<br />
<br />
b</p>

So the tags are somehow printed verbatim.

(I am not entering the tags in WYSIWYG mode.)

Im a bit confused since everything seems identical to the documentation (1) (2).

Would be great if someone could help me out. Cheers.


Solution

  • {{group.content | raw}}
    

    See https://twig.symfony.com/doc/2.x/filters/raw.html

    Bolt uses the Twig template engine. As such, all default twig {{ |filters }} also work in Bolt. Most of these have a similar meaning in plain PHP or Javascript. The available filters are: abs, batch, capitalize, convert_encoding, date, date_modify, default, escape, first, format, join, json_encode, keys, last, length, lower, merge, nl2br, number_format, raw, replace, reverse, round, slice, sort, split, striptags, title, trim, upper, url_encode.