0

From my understanding, Template::Alloy::TT should be interchangable with Template Toolkit, however I am having some issues trying to swap one out with the other. Here is the config for my view file:

package maypp::View::HTML;
use strict;
use base 'Catalyst::View::TT';

__PACKAGE__->config({
    INCLUDE_PATH => [
        myapp->path_to( 'root', 'src' ),
        myapp->path_to( 'root', 'lib' ),
    ],  
    PRE_PROCESS  => 'config/main',
    WRAPPER      => 'site/wrapper',
    ERROR        => 'error.html',
    TIMER        => 0,
    render_die   => 1,
    COMPILE_DIR => '/tmp/compiled_templates', #caches compiled templates
    STAT_TTL => 1, #how long to cache templates before seeing if there are any changes
    TEMPLATE_EXTENSION => '.html',
});

I thought that changing Catalyst::View::TT to Catalyst::View::TT::Alloy would be all I had to do to begin using Template::Alloy (this has been the procedure for me before). However, whenever I change this I do not get the correct output. Below is my wrapper file:

[% 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 "$host/site/html" + "$host/site/layout";
   END;
-%]

site/html will be processed, however site/layout does not go into site/html like it does when I just use regular Template Toolkit (typically site/layout goes into [% content %] in site/html). Is there something I'm doing wrong here? I'd like to use Template::Alloy for the speed increase, but that's only if I can get it working :) Thanks for the help!

srchulo
  • 5,143
  • 4
  • 43
  • 72

1 Answers1

0

Just taking a stab in the dark, I'd say TT::Alloy might not support the multiple WRAPPER + directive. In quite a few years of TT development, I've never used it, but that's not to say it isn't popular somewhere. My experience is an app might switch between wrapper A and wrapper B based on context, but wrapping B within A? Not so much.

If you're always going to need to do that though, why not put the second WRAPPER directive inside $host/site/html.tt ?

RET
  • 9,100
  • 1
  • 28
  • 33
  • well what's interesting is `content WRAPPER /site/html + site/layout;` works fine, however I need `$host` to display different templates depending on the domain. And by put the second `WRAPPER` directive inside `$host/site/html.tt`, you mean just try having `[% content WRAPPER "$host/site/layout" %]` instead of just `[% content %]` like I have now? – srchulo May 30 '13 at 00:32
  • Well in that case, perhaps it's an issue with the interpolation of `$host`? Try `host _ '/site/html'` and see if that makes any difference. – RET May 30 '13 at 00:40
  • I tried that, but then it gives me this error: `file error - /site/layout absolute paths are not allowed (set ABSOLUTE option)` – srchulo May 30 '13 at 17:59
  • Well, that suggests that the host variable is empty. Try something like `[% SET t1 = host _ '/site/html'; t1 | stderr; WRAPPER t1; -%]` and see what it's producing. – RET May 30 '13 at 23:28