in reply to HTML::Template Plugin

Hi

Have you seen Mojolicious::Plugin::HTMLTemplateProRenderer?

It always shows a handler => 'tmpl' argument to render, your example doesn't have it

  • Comment on Re: Mojolicious HTMLTemplateProRenderer

Replies are listed 'Best First'.
Re^2: Mojolicious HTMLTemplateProRenderer
by Maresia (Beadle) on Feb 15, 2017 at 02:09 UTC
    I tried loading the template file from another location, it's own directory and not within the code and I can't find a way to do it as well. Interesting!

      Hi,

      Did you use https://metacpan.org/pod/Mojolicious::Renderer#paths to tell mojo about this directory?

      update: foo.pl

      #!/usr/bin/env perl use Mojolicious::Lite; plugin 'HTMLTemplateProRenderer'; get '/' => sub { my $c = shift; return $c->render( 'hi', t1 => 'the first t1', ); }; my $paths = app->renderer->paths; unshift @$paths, 'exists'; app->start; __DATA__ @@ hi.html.tmpl <p> from __DATA__ its @@ hi.html.tmpl <p> <TMPL_VAR NAME="t1">

      $ perl foo.pl get / [Tue Feb 14 19:24:14 2017] [debug] GET "/" [Tue Feb 14 19:24:14 2017] [debug] Routing to a callback [Tue Feb 14 19:24:14 2017] [debug] 200 OK (0.00174s, 574.713/s) <p> from __DATA__ its @@ hi.html.tmpl <p> the first t1 $ mv not_templates templates $ perl foo.pl get / [Tue Feb 14 19:24:27 2017] [debug] GET "/" [Tue Feb 14 19:24:27 2017] [debug] Routing to a callback [Tue Feb 14 19:24:27 2017] [debug] 200 OK (0.001793s, 557.724/s) <p> from templates its hi.html.tmpl <p>the first t1 $ mv not_exists exists $ perl foo.pl get / [Tue Feb 14 19:24:53 2017] [debug] GET "/" [Tue Feb 14 19:24:53 2017] [debug] Routing to a callback [Tue Feb 14 19:24:53 2017] [debug] 200 OK (0.001772s, 564.334/s) <p> from exists its hi.html.tmpl <p> the first t1
        Hi, I know the code would work with the "SelfLoader", I am trying to make it work without any template code attached to the Perl code, without this part:
        __DATA__ @@ hi.html.tmpl <p> from __DATA__ its @@ hi.html.tmpl <p> <TMPL_VAR NAME="t1">
        and load it separated, this template code would be in its own directory, like in /templates or something. Thanks!