Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I override WRAPPER in a Template Toolkit template file?

Is there a way to disabling a WRAPPER that was set in new(\%config), through either the template, or a temporary override with parse()? I want to have a single default WRAPPER (that I'll use for 99.9% of my templates), but exclude a few.

I'm doing this all through Catalyst::View::TT just like the example in the configuration synopsis, except I don't want the WRAPPER to apply to all of my templates.

like image 309
NO WAR WITH RUSSIA Avatar asked Feb 19 '10 21:02

NO WAR WITH RUSSIA


1 Answers

Edit the wrapper, to include a conditional like:

[% IF no_wrapper OR template.no_wrapper %] [% content %] [% ELSE %]
  top;
    [% content %]
  bottom;
[% END %]

This allows me to disable the wrapper either (1) inside of template, or (2) from the stash.

  1. [%- META no_wrapper = 1 -%]
  2. $c->stash->{no_wrapper} = 1

META var ...; is a directive that makes var accessible through the template hash as template.var

source: http://wiki.catalystframework.org/wiki/gettingstarted/howtos/template_wrappers

like image 53
Martin Avatar answered Oct 23 '22 07:10

Martin