[dancer-users] Injecting templates
Warren Young
warren at etr-usa.com
Wed Nov 21 18:31:55 GMT 2018
On Nov 21, 2018, at 4:56 AM, Zahir Lalani <ZahirLalani at oliver.agency> wrote:
>
> Parent_controller
> Call sub_module
> Return template abc
>
> New
> Parent Controller
> $Inject = sub_module ; (renders a tt)
>
> Template xyz { parent_info = $x, inject_info = $inject }
The return from a Dancer “template” call is HTML, so you can just use it directly when rendering a sub-element. (Assuming the template is in fact written in HTML.)
I cover this technique in my Perl Advent Calendar 2016 article series:
http://advent.perldancer.org/2016/3
http://advent.perldancer.org/2016/4
http://advent.perldancer.org/2016/5
http://advent.perldancer.org/2016/6
http://advent.perldancer.org/2016/7
This specific bit is in the middle article under "Factor Common UI Elements Out”. It will help to read the whole series, since it’s describing a set of concepts that hang logically together.
More information about the dancer-users
mailing list