in reply to Re^3: HTML::Template Plugin
in thread HTML::Template Plugin

I looked at this one as well, still I can't see how to use it with an external template file, do you know of any sample code?

Replies are listed 'Best First'.
Re^5: HTML::Template Plugin
by Anonymous Monk on Feb 14, 2017 at 22:57 UTC
    O__O
    use Mojolicious::Lite; plugin 'HTMLTemplateProRenderer'; # Route leading to an action that renders a template get '/' => sub { my $c = shift; $c->stash(one => 23); $c->render(template => 'home', two => 24, handler => 'tmpl'); }; app->start; __DATA__ @@ home.html.tmpl The magic numbers are <tmpl_var one> and <tmpl_var two>.
      That works using __DATA__, but how could it work by using an external template file as this:
      #!/usr/bin/env perl use Mojolicious::Lite; plugin 'HTMLTemplateProRenderer'; # Route leading to an action that renders a template get '/test' => sub { my $c = shift; $c->stash(one => 23); $c->render(template => 'index', two => 24, handler => 'tmpl'); }; app->start;

      Here is the external in templates/index.tmpl file:
      <html> <head><title>Test Template</title> <body> Value ONE = <TMPL_VAR one> <p> Value TWO = <TMPL_VAR two> </body> </html>

      Thanks!