encode

The encode attribute, when set to true, converts special characters to HTML entities. This is the the opposite of what the html attribute does.

By default the Perch template engine converts special characters to HTML entities. When you want to override this behaviour for a tag use encode="false"

<perch:content id="categories" type="hidden" encode="false">

Passing HTML from outside the template

Render trusted HTML only

Avoid rendering HTML from user-provided content or third parties as this can lead to XSS attacks.

The encode attribute is useful when passing HTML from outside the template (see: Passing variables into templates):

perch_content_custom('My region', [
    'data' => [
        'title'         => '<h2 class="title">Some Heading</h2>',
        'categories'    => perch_categories([], true),
    ],
]);
<perch:content id="title" type="hidden" encode="false">
<perch:content id="categories" type="hidden" encode="false">