[dancer-users] Injecting templates

Dave Cross dave at dave.org.uk
Wed Nov 21 16:38:53 GMT 2018


Are you looking for the "layout" option?

    template 'some_page.tt, \%vars, { layout => undef };

Dave...
On Wed, 21 Nov 2018 at 16:07, Zahir Lalani <ZahirLalani at oliver.agency> wrote:
>
> Hi Will
>
>
>
> No I don’t think this helps – let me clarify
>
>
>
> Imagine a master page split into 4 quarters. Each quarter is effectively a widget whose output is determined by a separate module. We would need to call a package which would run some code, and using that data render a tt file without inserting this into “layout”. The parent would call 4 packages and receive 4 sets of html.
>
>
>
> The master would then have a final tt file which includes 4 variables which are replaced with the outputs from the above. This is then finally rendered into layout.
>
>
>
> Hope that clarifies
>
>
>
> Z
>
>
>
> From: dancer-users <dancer-users-bounces at dancer.pm> On Behalf Of William Carr
> Sent: 21 November 2018 15:59
> To: Perl Dancer users mailing list <dancer-users at dancer.pm>
> Subject: Re: [dancer-users] Injecting templates
>
>
>
>
>
>
>
> On Nov 21, 2018, at 6:56 AM, Zahir Lalani <ZahirLalani at oliver.agency> wrote:
>
>
>
> Hi All
>
>
>
> Need some guidance as to the options available
>
>
>
> I currently have a module which renders a template as a whole page. I want to separate some stuff as its getting a little messy
>
> This module is called by a parent controller. I want the parent controller to effectively call a master template render, and into that template I want to inject the content generated by the above sub module.
>
>
>
> So to be clear:
>
> Current:
>
>
>
> 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 parent template would simply then have a variable where the $inject output is replaced
>
>
>
> “template” is designed to render the whole page using layout – I am looking for something similar to the process template control of template toolkit.
>
>
>
> Hope I made myself clear
>
>
>
> Z
>
> Hi, Z.
>
>
>
> I’m not exactly sure what you are trying to achieve but perhaps template cascading from Text::Xslate may help.
>
>
>
> https://metacpan.org/pod/Text::Xslate::Syntax::Kolon#Template-cascading
>
>
>
> Cheers,
>
> Mr. Maloof
>
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users


More information about the dancer-users mailing list