Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Twig code in Prism Highlighter with Twig processing enabled

plugins

Solved by pamtbaau View solution

Started by Karmalakas 5 years ago · 2 replies · 756 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 themetman, 1 day ago
2 42 19 hours ago
General · by Hanns Mattes, 1 week ago
0 123 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago