Re: [Mojolicious] How include HTML as HTML in templates?

2015-11-30 Thread Helmut Wollmersdorfer
Oh, thx.

It's always good to have more than one solution.

Let me ask an additional question.

The HTML to include is large, typically ~100 KB, and can be prepared down 
to the necessary fragment in batch. Batch manipulation is still necessary 
for other reasons. This does not save much of the size, but safes parsing 
and stringification in the online app.

What would be expected to be the fastest method to include it in an 
template? It lives as a file, and I have a path as string.

TIA

Helmut Wollmersdorfer

Am Montag, 30. November 2015 10:39:49 UTC+1 schrieb Jan Henning Thorsen:
>
> You can also turn the string into a ByteStream object:
>
>   # this... 
>   use Mojo::ByteStream "b";
>   my $x = b "hello!";
>   $c->stash(x => $x);
>
>   # or this...
>   $c->stash(x => $c->b("Hello!"));
>
>
>
> https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Plugin/DefaultHelpers.pm#b
>
>
> On Monday, November 23, 2015 at 9:45:32 AM UTC+1, Helmut Wollmersdorfer 
> wrote:
>>
>>
>>
>> Am Montag, 23. November 2015 09:22:04 UTC+1 schrieb Luc didry:
>>>
>>>
>>> Simple: just use <%== instead of <%= (which XML escape the result). 
>>>
>>
>> OMG, forgot this  feature.
>>
>> Thx
>>
>> Helmut Wollmersdorfer
>>
>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How include HTML as HTML in templates?

2015-11-30 Thread Jan Henning Thorsen
You can also turn the string into a ByteStream object:

  # this... 
  use Mojo::ByteStream "b";
  my $x = b "hello!";
  $c->stash(x => $x);

  # or this...
  $c->stash(x => $c->b("Hello!"));


https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Plugin/DefaultHelpers.pm#b


On Monday, November 23, 2015 at 9:45:32 AM UTC+1, Helmut Wollmersdorfer 
wrote:
>
>
>
> Am Montag, 23. November 2015 09:22:04 UTC+1 schrieb Luc didry:
>>
>>
>> Simple: just use <%== instead of <%= (which XML escape the result). 
>>
>
> OMG, forgot this  feature.
>
> Thx
>
> Helmut Wollmersdorfer
>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.


Re: [Mojolicious] How include HTML as HTML in templates?

2015-11-23 Thread Luc didry
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 = 'test';
> 
>   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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.