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

Html tags showing in content

Started by Muut Archive 9 years ago · 4 replies · 1366 views
9 years ago

I've created listing.yaml and listing.html.twig in themes/g5_helium/custom. I'm able to use this to create a page with my custom fields, but when I view the page I can see the <p> tags being printed out as plain text. I'm using an exact copy of default.html.twig for listing.html.twig.

9 years ago

I fixed it. I needed to use {{ page.content|raw }} instead of {{ page.content }}.

9 years ago

But I don't understand why. Isn't the markup being added intentionally by the Markdown editor? Why do I need to strip it away before presenting it?

9 years ago

Markdown automatically adds paragraph tags when there are two newlines in the content. If you don't want markdown processing, you can disable it site or page-wide via:

YAML
process:
   markdown: false
9 years ago

Thanks for the reply. I understand that the paragraph tags are automatically entered, but I don't understand why I have to manually strip them in my template when markdown processing is enabled. My assumption is that I would be able to edit my content using Markdown and that's what would be printed to the template, and that the template wouldn't have to wrap the content in html markup because that's already being done by markdown: true. What am I missing in my understanding?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2933 9 years ago
Archive · by Muut Archive, 9 years ago
3 1110 9 years ago