xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I'm new to Catalyst and intend to write a website in it. Now what I am stuck is I want to use one wrapper for some templates, and the other one for some other templates. But as Catalyst tutorial, I'm just able to define only one wrapper like this:

__PACKAGE__->config( # Change default TT extension TEMPLATE_EXTENSION => '.tt2', # Set the location for TT files INCLUDE_PATH => [ MyApp->path_to( 'root', 'src' ), ], # Set to 1 for detailed timer stats in your HTML as comments TIMER => 0, # This is your wrapper template located in the 'root/src' WRAPPER => 'wrapper.tt2', );

Any thoughts are appreciated!





I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: Catalyst WRAPPER
by Anonymous Monk on Jun 06, 2010 at 06:52 UTC

      That is only partially useful, as the setting being asked about is actually the setting within Catalyst to specify which file will be used as the default wrapper for all responses.

      xiaoyafeng, I would suggest using conditional logic in the wrapper template itself to override the default (i.e. most commonly used) behaviour by doing something like setting a flag in the stash.

      It is the best I have been able come up with so far and I would be interested to hear about a more elegant solution if it is available.

        The setting happens to be set within a Catalyst view class but it's still purely a Template setting and has nothing specifically Catalyst about it. That's rather the point of the M and the V in MVC. So the best answer to this would probably come from the TT archives/list though the Cat resources have help too, and xiaoyafeng asked there too got a couple decent answers and a pointer to http://wiki.catalystframework.org/wiki/gettingstarted/howtos/template_wrappers.

        A stash variable named "wrapper" to override the view's default is a fine way to go. I recommend against subclasses per wrapper as suggested earlier. One TT view is enough considering how easy it is to customize arbitrary wrappers.