0

I'm adding a string with HTML <br> within it to the stash. This stash value is then used to populate a text area.

The problem is the browser converts the > and < to lt; and gt; and it displays wrong in the browser. Is there a way to stop this from happening?

$string = "line 1<br>line 2<br>line 3";
$self->stash(info => $string);
$self->render('infopage');
tvanfosson
  • 524,688
  • 99
  • 697
  • 795
user1768233
  • 1,409
  • 3
  • 20
  • 28

1 Answers1

2

When you display text, you use this:

<%= $var %>

Or this

%= $var

This syntax will convert > to gt; and < to lt;

You must to use this syntax if you want to to except conversation

<%== $var %>

Or this

%== $var

So, simply add symbol =, but it is not security.

Logioniz
  • 891
  • 6
  • 15
  • 1
    Thank you! Such a simple solution to my problem. I missed this in the documentation. "<%= Perl expression, replaced with result %> <%== Perl expression, replaced with XML escaped result %>" – user1768233 Jun 15 '14 at 09:10