* Curtis Poe <[EMAIL PROTECTED]> [2002-04-09 18:12]:
> A few days ago, I was asking about how to automatically include the
> template name in start and end tags at the beginning and end of each
> INCLUDEd template (original email is below).

[-- snip --]

> Frankly, I don't know a heck of a lot about the internals of Template
> Toolkit, but this seemed to work just fine.  Are there any pitfalls to
> this approach?

Can't you subclass Template::Context to get the same effect more
cleanly?

  package My::Template::Context;

  use Template::Context;
  use base qw(Template::Context);

  sub include {
      my $class = shift;
      my $tmpl = $_[0];
      my $data = join "\n",
          "<!-- START: $tmpl -->",
          $class->SUPER::include(@_),
          "<!-- END: $tmpl -->";

      return $data;
  }

  1;

And then, in your processor:

  use Template::Config;
  Template::Config::CONTEXT_MODULE = "My::Template::Context";

And proceed as usual?

(darren)

-- 
UNIX is a process that runs under Emacs.


Reply via email to