Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

selectively using the wrapper

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


tech at swattermatter

Sep 15, 2009, 2:55 PM

Post #1 of 9 (1728 views)
Permalink
selectively using the wrapper

I want to load a page, but not run it through the wrapper. Can I shut
off the wrapper or specify different wrappers at different times?

I have read the Catalyst::View::TT doc, but it doesn't mention this.

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


2009 at denny

Sep 15, 2009, 3:28 PM

Post #2 of 9 (1645 views)
Permalink
Re: selectively using the wrapper [In reply to]

On Tue, 2009-09-15 at 17:55 -0400, Ascii King wrote:
> I want to load a page, but not run it through the wrapper. Can I shut
> off the wrapper or specify different wrappers at different times?
>
> I have read the Catalyst::View::TT doc, but it doesn't mention this.

Someone was nice enough to answer this question for me when I posed it
on the #tt channel on irc.perl.org earlier today, so it would be rude of
me not to pass on the answer:


===== wrapper.tt =====

[.% IF template.custom_wrapper;
PROCESS $template.custom_wrapper;
ELSIF no_wrapper || template.no_wrapper;
content;
ELSE;
PROCESS 'default_wrapper.tt';
END
%]


===== a_template.tt =====

[.%
META custom_wrapper = 'alt_wrapper.tt';
META title = 'Alt Layout';
-%]

<!-- rest of template goes here -->


Add default and alt wrapper templates to flavour :)

Hope that makes sense!

Regards,
Denny
Attachments: signature.asc (0.19 KB)


tech at swattermatter

Sep 16, 2009, 7:20 AM

Post #3 of 9 (1629 views)
Permalink
Re: selectively using the wrapper [In reply to]

> Someone was nice enough to answer this question for me when I posed it
> on the #tt channel on irc.perl.org earlier today, so it would be rude of
> me not to pass on the answer:
>
>
> ===== wrapper.tt =====
>
> [.% IF template.custom_wrapper;
> PROCESS $template.custom_wrapper;
> ELSIF no_wrapper || template.no_wrapper;
> content;
> ELSE;
> PROCESS 'default_wrapper.tt';
> END
> %]
>
>
> ===== a_template.tt =====
>
> [.%
> META custom_wrapper = 'alt_wrapper.tt';
> META title = 'Alt Layout';
> -%]
>
> <!-- rest of template goes here -->
>
>
Thanks, Denny. that's perfect. Just to complete the question for the
archives, you would call the no_wrapper like this:
$c->stash->{no_wrapper => 1};
$c->stash->{template} = 'account/display_account.tt2';

I don't know how to set the template.custom_wrapper, though. I ended up
just using a variable in the stash called custom_wrapper and then
deleting the 'template.' from the example above.

$c->stash->{custom_wrapper} = 'my_special_wrap.tt2';

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


2009 at denny

Sep 16, 2009, 7:33 AM

Post #4 of 9 (1641 views)
Permalink
Re: selectively using the wrapper [In reply to]

On Wed, 2009-09-16 at 10:20 -0400, Ascii King wrote:
> > [.% IF template.custom_wrapper;
> > PROCESS $template.custom_wrapper;
> > ELSIF no_wrapper || template.no_wrapper;
> > content;
> > ELSE;
> > PROCESS 'default_wrapper.tt';
> > END
> > %]
>
> I don't know how to set the template.custom_wrapper, though.

Ah, that was a pure TT solution - to set a template.variable you use
'META variable = ...' in the calling template.

> I ended up just using a variable in the stash called custom_wrapper
> and then deleting the 'template.' from the example above.

Sounds good.
Attachments: signature.asc (0.19 KB)


moseley at hank

Sep 16, 2009, 7:38 AM

Post #5 of 9 (1628 views)
Permalink
Re: selectively using the wrapper [In reply to]

On Wed, Sep 16, 2009 at 7:20 AM, Ascii King <tech [at] swattermatter> wrote:

>
>
>> [.%
>> META custom_wrapper = 'alt_wrapper.tt';
>> META title = 'Alt Layout';
>> -%]
>>
>> <!-- rest of template goes here -->
>>
>>
>>
>
> I don't know how to set the template.custom_wrapper, though. I ended up
> just using a variable in the stash called custom_wrapper and then deleting
> the 'template.' from the example above.
>

Just like the example above.


>
> $c->stash->{custom_wrapper} = 'my_special_wrap.tt2';


In my mind the wrapper is a view issue, so I set the wrapper in the template
not in the controller. I have a wrapper that is called for *every* page
that is used to build the page.

META is compile time, IIRC, so I use [% page.layout = 'foo' %] then in
wrapper.tt I have a CASE statement that
sets the wrappers based on page.layout set in the base template.

IIRC, I use page.layout (instead of say just "layout") because WRAPPER does
a shallow localization of the stash.





--
Bill Moseley
moseley [at] hank


tech at swattermatter

Sep 16, 2009, 9:11 AM

Post #6 of 9 (1634 views)
Permalink
Re: selectively using the wrapper [In reply to]

Bill Moseley wrote:
>
> In my mind the wrapper is a view issue, so I set the wrapper in the
> template not in the controller. I have a wrapper that is called for
> *every* page that is used to build the page.
>
> META is compile time, IIRC, so I use [% page.layout = 'foo' %] then in
> wrapper.tt <http://wrapper.tt> I have a CASE statement that
> sets the wrappers based on page.layout set in the base template.
>
> IIRC, I use page.layout (instead of say just "layout") because WRAPPER
> does a shallow localization of the stash.
>

Thanks again, guys. It took me a few reads to figure out what this
meant, but I'm glad I understand it now. I agree that the wrapper should
be called from the template. I suspect it will make my life a little easier.

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


moseley at hank

Sep 16, 2009, 12:46 PM

Post #7 of 9 (1630 views)
Permalink
Re: selectively using the wrapper [In reply to]

On Wed, Sep 16, 2009 at 9:11 AM, Ascii King <tech [at] swattermatter> wrote:

> Bill Moseley wrote:
>
>>
>> In my mind the wrapper is a view issue, so I set the wrapper in the
>> template not in the controller. I have a wrapper that is called for *every*
>> page that is used to build the page.
>>
>> META is compile time, IIRC, so I use [% page.layout = 'foo' %] then in
>> wrapper.tt <http://wrapper.tt> I have a CASE statement that
>> sets the wrappers based on page.layout set in the base template.
>>
>> IIRC, I use page.layout (instead of say just "layout") because WRAPPER
>> does a shallow localization of the stash.
>>
>>
> Thanks again, guys. It took me a few reads to figure out what this meant,
> but I'm glad I understand it now. I agree that the wrapper should be called
> from the template. I suspect it will make my life a little easier.


Not sure what you mean by "template" there, but maybe this makes it clearer:

View::TT:
COMPILE_DIR: __TEMPDIR(templates)__
WRAPPER: page/wrapper.tt
PRE_PROCESS: config.tt
PRE_CHOMP: 0
POST_CHOMP: 0
TIMER: 0
STAT_TTL: 60
ENCODING: UTF-8

Template Toolkit then will call page/wrapper.tt for template passed to
process(). Then the template sets the page.layout and
page/wrapper.ttdecides how to build the entire page based on that
layout.





--
Bill Moseley
moseley [at] hank


tlyons at ivenue

Sep 20, 2009, 8:38 PM

Post #8 of 9 (1527 views)
Permalink
Re: selectively using the wrapper [In reply to]

On Wed, Sep 16, 2009 at 7:20 AM, Ascii King <tech [at] swattermatter> wrote:
> Thanks, Denny. that's perfect. Just to complete the question for the
> archives, you would call the no_wrapper like this:
> $c->stash->{no_wrapper => 1};

Is this a typo? Should it be () instead of {} ? I've never seen
this, but I will experiment with it tomorrow and see what happens when
I try it...

--
Regards... Todd

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


pagaltzis at gmx

Sep 20, 2009, 9:49 PM

Post #9 of 9 (1538 views)
Permalink
Re: selectively using the wrapper [In reply to]

* Todd Lyons <tlyons [at] ivenue> [2009-09-21 05:45]:
> On Wed, Sep 16, 2009 at 7:20 AM, Ascii King <tech [at] swattermatter> wrote:
> > Thanks, Denny. that's perfect. Just to complete the question
> > for the archives, you would call the no_wrapper like this:
> > $c->stash->{no_wrapper => 1};
>
> Is this a typo? Should it be () instead of {} ?

Yes. It should be either of the following:

$c->stash->{no_wrapper} = 1;
$c->stash( no_wrapper => 1 );

I always prefer the latter.

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.