[Catalyst] selectively using the wrapper

Ascii King tech at swattermatter.com
Wed Sep 16 14:20:45 GMT 2009


> 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';



More information about the Catalyst mailing list