Ask Your Question
1

What is the method for inserting and returning HTML code using a Twig function?

asked 2021-10-31 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-04-16 10:00:00 +0000

plato gravatar image

The method for inserting and returning HTML code using a Twig function is by using the raw filter.

Here's an example:

{% set html = '<p>Hello, world!</p>' %}

{{ html|raw }}

The raw filter will prevent the HTML code from being escaped by Twig, allowing it to be outputted as-is.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-31 11:00:00 +0000

Seen: 11 times

Last updated: Apr 16 '21