11

I am trying to send HTML to a template in Mojolicious and am finding that the html is getting replaced with safe strings somewhere along the way.

$self->stash(portalHeaderHtml => "<html>");

Becomes

 &lt;html&gt;

In the source

The template:

<%= $portalHeaderHtml %>

How do I tell it to display HTML and not replace tags?

Zaid
  • 36,680
  • 16
  • 86
  • 155
shaneburgess
  • 15,702
  • 15
  • 47
  • 66

1 Answers1

19

Mojolicious::Guides::Rendering suggests using == to disable escaping of characters.

An additional equal sign can be used to disable escaping of the characters <, >, &, ' and " in results from Perl expressions, which is the default to prevent XSS attacks against your application.

<%== '<p>test</p>' %>

Proceed with caution.

smonff
  • 3,399
  • 3
  • 36
  • 46
Zaid
  • 36,680
  • 16
  • 86
  • 155