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 · 535 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 Hanns Mattes, 17 hours ago
1 21 9 hours ago
General · by Andy Miller, 10 hours ago
0 21 10 hours ago
General · by Jerry Hunt, 5 days ago
2 143 2 days ago
General · by pamtbaau, 2 days ago
1 95 2 days ago
General · by Andy Miller, 2 days ago
0 79 2 days ago