Le Monday 23 November 2015, 00:10:39 Helmut Wollmersdorfer a écrit :
> Hi,
>
> I want to include HTML as content into a template.
>
> This is my code so far:
>
> sub show {
> my $self = shift;
>
> my $html = '<b>test</b>';
>
> my $dom = Mojo::DOM->new($html);
>
> my $content = $dom->at('div.ocr_page')->to_string;
>
> $self->stash->{hocr} = $content;
>
> $self->render();
> }
>
> And the template:
>
> % layout 'default';
>
> <%= $hocr %>
>
> But this renders the HTML as text, i.e. the markup is displayed.
>
> Solution?
>
> TIA
>
> Helmut Wollmersdorfer
Simple: just use <%== instead of <%= (which XML escape the result).
http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Embedded-Perl
Regards,
--
Luc
https://fiat-tux.fr/
Internet n'est pas compliqué, Internet est ce que vous en faites.
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.