On Sat, 22 Aug 2020 16:32:53 -0500
Richard Reina <gatorre...@gmail.com> wrote:
>   template 'softball.tt' => {
>       
>       'title' => 'Get Softball Season Stats',
>       'Season' => $season,
>       
>       
>     }, {};
> 
> But I am lost trying to get it to display with template toolkit.
> Here's what I've tried so far.
> 
> <table style="width:100%; line-height:40px;">
>         <% FOREACH Season = Season %>
>         <tr>
>           <td width="5">Season.key <% Season.key %></td>
>           <td width="5">Season.val <% Season.value %></td>
>           <td width="5">Season.val.atbats <% Season.value.atbats %>
>           <td width="5">Season.val.hits <% Season.value.hits %>
>         </tr>
>         <% END %>

Looks generally plausible.  What actually happens?  Do you get an
error when you try it?

Taking that code and turning it in to a self-contained test case works.

Could it be as simple as having configured Dancer to use typical TT
start and end tags e.g. `[%` and `%]`?

Or not actually having Template Toolkit selected as the template engine
in use?

Or your route handler executing template(), but then returning
something different?  (Running template() returns the result of
processing the template; if it's the last thing in the route handler
coderef, as it usually would be, then that'll be fine, e.g.:

  get '/foo' => sub {
      # do some stuff
      template('foo.tt', ...);
  };

... in that case, template()'s return, i.e. the processed content
generated by the template, is implicitly returned to the caller.

However, e.g.

  get '/foo' => sub {
    template('foo.tt', ...);
    return "Done";
  };

... the template content generated isn't returned by the route
handler, so will not be used.

Cheers

Dave P

 
_______________________________________________
dancer-users mailing list
dancer-users@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to