Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

TWIG Escape Filter

Started by Dennis 6 years ago · 1 replies · 800 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 Old Man Umby, 1 week ago
2 114 3 hours ago
General · by jeremycherfas, 2 weeks ago
5 204 15 hours ago
General · by lynbor, 6 days ago
2 133 4 days ago
General · by Sebastian, 2 weeks ago
1 133 2 weeks ago
General · by Andy Miller, 3 weeks ago
0 256 3 weeks ago