Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Twig code in Prism Highlighter with Twig processing enabled

plugins

Solved by pamtbaau View solution

Started by Karmalakas 5 years ago · 2 replies · 676 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 Andy Miller, 3 days ago
0 66 3 days ago
General · by lynbor, 4 weeks ago
3 409 1 week ago
General · by lynbor, 2 weeks ago
7 520 1 week ago
General · by Harry, 1 week ago
0 142 1 week ago
General · by Old Man Umby, 4 weeks ago
2 288 3 weeks ago