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.

Content & Markdown

Escaping html when importing yaml

Started by Mike 9 years ago · 3 replies · 1093 views
9 years ago

I am using the 'import' plugin to work with both json and yaml files.

For json I have used

{{ page.header.imports.ex_config|json_encode(constant('JSON_PRETTY_PRINT') b-or constant('JSON_UNESCAPED_SLASHES'))|e('html') }}

This successfully escapes fields in the json file which contain xml data.

How do I achieve the same when importing a yaml file?

9 years ago

I have managed to achieve this using the twig documentation on escaping as at https://twig.symfony.com/doc/2.x/api.html#escaper-extension

Using

TWIG
{% autoescape 'html' %}
{{ page.header.imports.file1.x|yaml_emit }}
{% endautoescape %}

works for the most part, although I am having difficulty with the processor removing a >- block chomping indicator

9 years ago

I wanted to but it is a forked repo and he doesn't seem to have enabled issues

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 97 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 185 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago