Using Kirby blocks with twig

Hey there!

I was wondering if there is a way to use the blocks field with twig. At the moment it renders the php snippets as a string including the html tags in the dom.

Using the given code from the docs:

    type: blocks

<p>hello world</p>
{{ page.text.toBlocks() }}

results in the following for me:


My Kirby installation is running on version with the following plugins:

  • kirby-blurry-placeholder
  • kirby-twig
  • markdown-field

Is there a way to use the given snippets with twig? Thanks a lot in advance!

That’s because Twig by default ({{ var }}) renders the content escaped - that’s all the special characters like < encoded as &lt;, for instance. What you want is to output the HTML as it is, and that’s… checks Twig docs… with a raw filter: {{ page.text.toBlocks() | raw }}

That worked! Thank you!