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 Escape Filter

Started by Dennis 7 years ago · 1 replies · 933 views
7 years ago

I'm reading through some of my theme code to understand everything in it. The < title> uses the Escape filter for TWIG:

{{ site.title|e('html') }}

It took a little digging around to find out what the e filter even was. I found it under "escape" in the TWIG documentation. I did not put this filter here, it was in a skeleton theme I used as a starting point (pure-blank).

Why is this filter applied here? What would be a case where it is needed? I did some experimenting. I removed it and left {{ site.title }} , then I edited my config/site.yaml file so that title: had special characters (specifically I added < b> to the title) thinking that it might break something. Everything is fine and < b> shows up in the site title, so why is this even applied here?

7 years ago

Not being an expert at all on this matter I would say using e(html) or the equivalent e filter for a page title isn't needed at all.

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by themetman, 24 hours ago
2 40 17 hours ago
General · by Hanns Mattes, 1 week ago
0 121 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