Oh and the include statement I'm using is %= include 'include/includeme'
in case anyone else wants to know! On Saturday, August 26, 2017 at 7:12:23 AM UTC+1, MarrsAttax wrote: > > Hi Jürgen > > Thanks for the reply, very helpful! > > I'd tried using include before without success but I've now discovered it > was because I had my relative paths confused. I thought that the layout > would always look for the included template at the same level as the layout > > e.g > > templates/layouts/default.html.ep > templates/layouts/includeme.html.ep > > but that doesn't work. The structure needs to be like this: > > templates/layouts/default.html.ep > templates/include/includeme.html.ep > > Thanks again :) > > On Friday, August 25, 2017 at 11:01:07 AM UTC+1, Juergen Nickelsen wrote: >> >> On 25.08.2017 09:13, MarrsAttax wrote: >> > Is it possible to share a common block of code between two different >> > layouts? I am writing a full mojo app (not mojo lite) and want to to >> > share a common header between two different layouts. >> >> That is what the "include" helper is for. >> >> http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Partial-templates >> >> >> I have been using it for some time with success, and only now I see you >> can even pass parameters to it! :-/ >> >> My own use case is mostly flash displays, like this: >> >> % if (stash('error_info')) { >> %= include 'include/error_info_box' >> % } >> % if (stash('success_message')) { >> %= include 'include/success_box' >> % } >> % if (stash('info_message')) { >> %= include 'include/info_box' >> % } >> >> Now that I see this, I think I even could pass the message type >> (error/info/success) through the stash to collapse these three cases to >> just one. Hmmm... >> >> Regards, Jürgen. >> >> -- >> Jürgen Nickelsen <[email protected]> >> Freie Universität Berlin, ZEDAT/FUDIS https://zedat.fu-berlin.de/FUDIS >> Jabber [email protected]; Tel +49.30.838-50740 Fax -450740 >> > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
