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

TWIG Escape Filter

Started by Dennis 6 years ago · 1 replies · 761 views
6 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?

6 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 jean-louis67, 3 weeks ago
2 308 3 weeks ago
General · by Andy Miller, 3 weeks ago
0 311 3 weeks ago
General · by Veehem, 4 weeks ago
0 263 4 weeks ago
General · by milkboy, 4 weeks ago
0 265 4 weeks ago
General · by ian russell, 1 month ago
2 335 1 month ago