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

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>.

Replies are listed 'Best First'.
Re^6: HTML::Template Plugin
by Anonymous Monk on Feb 14, 2017 at 23:58 UTC
    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!