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
On Nov 21, 2018, at 6:56 AM, Zahir Lalani <ZahirLalani@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
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@dancer.pm> On Behalf Of William Carr Sent: 21 November 2018 15:59 To: Perl Dancer users mailing list <dancer-users@dancer.pm> Subject: Re: [dancer-users] Injecting templates On Nov 21, 2018, at 6:56 AM, Zahir Lalani <ZahirLalani@oliver.agency<mailto:ZahirLalani@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
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@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@dancer.pm> On Behalf Of William Carr Sent: 21 November 2018 15:59 To: Perl Dancer users mailing list <dancer-users@dancer.pm> Subject: Re: [dancer-users] Injecting templates
On Nov 21, 2018, at 6:56 AM, Zahir Lalani <ZahirLalani@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@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Aha - that could be it Will give it a go Thx Dave Z
-----Original Message----- From: dancer-users <dancer-users-bounces@dancer.pm> On Behalf Of Dave Cross Sent: 21 November 2018 16:39 To: Perl Dancer users mailing list <dancer-users@dancer.pm> Subject: Re: [dancer-users] Injecting templates
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@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@dancer.pm> On Behalf Of William
Carr
Sent: 21 November 2018 15:59 To: Perl Dancer users mailing list <dancer-users@dancer.pm> Subject: Re: [dancer-users] Injecting templates
On Nov 21, 2018, at 6:56 AM, Zahir Lalani <ZahirLalani@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@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Nov 21, 2018, at 4:56 AM, Zahir Lalani <ZahirLalani@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.
Perfect Thx Warren Z
-----Original Message----- From: dancer-users <dancer-users-bounces@dancer.pm> On Behalf Of Warren Young Sent: 21 November 2018 18:32 To: Perl Dancer users mailing list <dancer-users@dancer.pm> Subject: Re: [dancer-users] Injecting templates
On Nov 21, 2018, at 4:56 AM, Zahir Lalani <ZahirLalani@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. _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (4)
-
Dave Cross -
Warren Young -
William Carr -
Zahir Lalani