Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Twig code in Prism Highlighter with Twig processing enabled

plugins

Solved by pamtbaau View solution

Started by Karmalakas 5 years ago · 2 replies · 622 views
5 years ago

Is there a way to use Twig code in Prism Highlighter when Twig processing for the page is enabled? Eg.

TWIG
```twig
{{ 'now'|date('Y') }}
```

Output: `{{ 'now'|date('Y') }}`

I'd want it to render on page:

TWIG
{{ 'now'|date('Y') }}

Output: 2021

But now I'm getting

TWIG
2021

Output: 2021

Simply put, I'd like to dispaly Twig code litterally (without processing) if it's in the ```twig ``` block

last edited 06/20/21 by Karmalakas
5 years ago Solution

@Karmalakas, Try the following:

<pre>

TWIG

{% verbatim %}
{{ 'now'|date('Y') }}
{% endverbatim %}

</pre>

This will yield:

{{ 'now'|date('Y') }}

5 years ago

Amazing :) That's exactly what I wanted :) Now I remember reading about verbatim some time ago on Twig docs :) Thank you

Suggested topics

Topic Participants Replies Views Activity
General · by jean-louis67, 3 weeks ago
2 312 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 312 3 weeks ago
General · by Veehem, 4 weeks ago
0 264 4 weeks ago
General · by milkboy, 4 weeks ago
0 267 4 weeks ago
General · by ian russell, 1 month ago
2 338 1 month ago