Search code examples
ajaxperlframeworkscatalysttemplate-toolkit

How do I use multiple Template Toolkit TTSite views on a Catalyst site?


I use Template Toolkit to generate views of pages in Catalyst. To do some basic Ajax, I want to have some output pages not use the TTSite style, but a much more basic structure. Do I put something special into the stash to use a .tt2 file without the header/footer/etc that automatically comes with the rest of my templates? (site generated following tutorial instructions.)


Solution

  • Aha, lib/projectname/View/TT.pm has:

    WRAPPER      => 'site/wrapper',
    

    and in root/lib/site/wrapper, I find:

    [% IF template.name.match('\.(css|js|txt)');
         debug("Passing page through as text: $template.name");
         content;
       ELSE;
         debug("Applying HTML page layout wrappers to $template.name\n");
         content WRAPPER site/html + site/layout;
       END;
    -%]
    

    So if I name my non-wrapper template .txt, I can avoid site/html + site/layout.

    Or maybe even better, I can make a .ajax extension and add that to the list of pass-through templates.