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

TWIG Escape Filter

Started by Dennis 6 years ago · 1 replies · 842 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 Andy Miller, 7 days ago
0 117 7 days ago
General · by lynbor, 1 month ago
3 445 2 weeks ago
General · by lynbor, 3 weeks ago
7 564 2 weeks ago
General · by Harry, 2 weeks ago
0 165 2 weeks ago
General · by Old Man Umby, 1 month ago
2 310 4 weeks ago