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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

TWIG Escape Filter

Started by Dennis 6 years ago · 1 replies · 638 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 Jerry Hunt, 4 days ago
2 95 15 hours ago
General · by pamtbaau, 20 hours ago
1 61 19 hours ago
General · by Andy Miller, 1 day ago
0 47 1 day ago
General · by Marcel, 12 months ago
6 356 5 days ago
General · by Duc , 6 days ago
3 44 6 days ago