Just adding my implementation for future reference

I added my changes in before_dispatch hook as I wanted some request 
variable to decide the actual path 

sub before_dispatch {
     my $self = shift;
     my $path = 'abc/xyz/';
     $self->app->renderer->paths([$path]); # update the renderer path here
} 

Thanks for all the answers

On Friday, 18 July 2014 12:18:39 UTC+8, Raunak Kathuria wrote:
>
> Thanks everyone for answers. Will try this out and post an update if it 
> needs any modification.
>
> On Thursday, 17 July 2014 23:25:35 UTC+8, Charlie Brady wrote:
>>
>>
>> On Wed, 16 Jul 2014, Raunak Kathuria wrote: 
>>
>> > Thanks for the answer, just basic query regarding this 
>> > 
>> > What is the best place to use this? Is it in Controller or Helpers or 
>> Hooks 
>> > or before every request to the layout? As i want it to be the default 
>> one 
>> > so as to use this all the time 
>>
>> You'll have to decide what is "best", but you can put it in your app like 
>> so: 
>>
>> use Mojolicious::Lite; 
>>
>> push @{app->renderer->paths}, '/path/to/your/templates'; 
>>
>> ... 
>>
>> app->start; 
>>
>>
>> > 
>> > On Thursday, 17 July 2014 11:34:42 UTC+8, Jonathan O wrote: 
>> > > 
>> > > This is probably a good start: 
>> > > 
>> > > http://mojolicio.us/perldoc/Mojolicious/Renderer#paths 
>> > > 
>> > > Jonathan Otsuka 
>> > > On Jul 16, 2014, at 10:00 PM, Raunak Kathuria <[email protected] 
>> > > <javascript:>> wrote: 
>> > > 
>> > > How can we load layout/templates from separate directory rather than 
>> the 
>> > > default template directory (on same hierarchy level of lib, public). 
>> I will 
>> > > explain the scenario 
>> > > As of now we use to load it from default template directory but now 
>> we are 
>> > > going to open source our templates for white-labeling so the 
>> directory 
>> > > structure will change and templates will be moved to altogether 
>> different 
>> > > separate directory 
>> > > 
>> > > For e.g say if earlier it was */home/git/parent/template* along with 
>> > > */home/git/parent/lib* at same level but now the templates will be 
>> moved 
>> > > to something like this */home/git/new_repo/template* but the lib will 
>> > > remain in same directory 
>> > > 
>> > > So how can we handle this scenario? Can we serve templates from 
>> different 
>> > > directory? 
>> > > 
>> > > -- 
>> > > 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] <javascript:>. 
>> > > To post to this group, send email to [email protected] 
>> > > <javascript:>. 
>> > > Visit this group at http://groups.google.com/group/mojolicious. 
>> > > For more options, visit https://groups.google.com/d/optout. 
>> > > 
>> > > 
>> > > 
>> > 
>> > 
>>
>
> On Thursday, 17 July 2014 23:25:35 UTC+8, Charlie Brady wrote:
>>
>>
>> On Wed, 16 Jul 2014, Raunak Kathuria wrote: 
>>
>> > Thanks for the answer, just basic query regarding this 
>> > 
>> > What is the best place to use this? Is it in Controller or Helpers or 
>> Hooks 
>> > or before every request to the layout? As i want it to be the default 
>> one 
>> > so as to use this all the time 
>>
>> You'll have to decide what is "best", but you can put it in your app like 
>> so: 
>>
>> use Mojolicious::Lite; 
>>
>> push @{app->renderer->paths}, '/path/to/your/templates'; 
>>
>> ... 
>>
>> app->start; 
>>
>>
>> > 
>> > On Thursday, 17 July 2014 11:34:42 UTC+8, Jonathan O wrote: 
>> > > 
>> > > This is probably a good start: 
>> > > 
>> > > http://mojolicio.us/perldoc/Mojolicious/Renderer#paths 
>> > > 
>> > > Jonathan Otsuka 
>> > > On Jul 16, 2014, at 10:00 PM, Raunak Kathuria <[email protected] 
>> > > <javascript:>> wrote: 
>> > > 
>> > > How can we load layout/templates from separate directory rather than 
>> the 
>> > > default template directory (on same hierarchy level of lib, public). 
>> I will 
>> > > explain the scenario 
>> > > As of now we use to load it from default template directory but now 
>> we are 
>> > > going to open source our templates for white-labeling so the 
>> directory 
>> > > structure will change and templates will be moved to altogether 
>> different 
>> > > separate directory 
>> > > 
>> > > For e.g say if earlier it was */home/git/parent/template* along with 
>> > > */home/git/parent/lib* at same level but now the templates will be 
>> moved 
>> > > to something like this */home/git/new_repo/template* but the lib will 
>> > > remain in same directory 
>> > > 
>> > > So how can we handle this scenario? Can we serve templates from 
>> different 
>> > > directory? 
>> > > 
>> > > -- 
>> > > 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] <javascript:>. 
>> > > To post to this group, send email to [email protected] 
>> > > <javascript:>. 
>> > > Visit this group at http://groups.google.com/group/mojolicious. 
>> > > For more options, visit https://groups.google.com/d/optout. 
>> > > 
>> > > 
>> > > 
>> > 
>> > 
>>
>

-- 
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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to