In my Symfony controller I provide an error message via FlashBag like so:
$this->get('session')->getFlashBag()->add('error', 'The code you provided didn't match what we expected.');
This renders the expected output, is it possible for me to add a link? So I would be able to output a message like:
The code you provided doesn’t match what we expected, if you have continued trouble, consider looking into common problems and how to solve them.
I’ve already tried adding in it in using markdown and HTML syntax, neither of which work, the documentation on the feature does not say if it is or is not possible, and there are currently no questions on SO that address this.
Advertisement
Answer
By default Twig will escape HTML to prevent any injection.
You have to add a filter that prevent your HTML from escape.
{{ flashMessage|raw }}