On Mon, Jun 30, 2008 at 10:11 AM, Blue Eyed Devil <
[EMAIL PROTECTED]> wrote:

>  To reiterate my example:
>
>  [% TAG %] is a [% TYPE %] that can be [% WORD %]
>
>  If I don't pass any vars to process(), there should be a collection,
> property, or method I could call that would work something like:
>
>  $template->process(....);
>  @all_tags = $template->tags();
>

I still don't really understand how this is meant to be useful, but you
could capture all of the tag contents by providing a custom Template::Parser
object that overrides the split_text() method.

Not-fully-tested code:

package MyParser;

our @ISA = qw(Template::Parser);

sub split_text {
  my ($self, $text) = @_;
  my $tokens = $self->SUPER::split_text($text);
  ref eq 'ARRAY' and ++$self->{alltags}{$$_[0]} for @$tokens;
  return $tokens;
}

sub tags {
  my $self = shift;
  return keys %{ $self->{alltags} };
}

And then:

my $parser = MyParser->new;
my $template = Template->new(PARSER => $parser);
$template->process(<whatever>);

my @all_tags = $parser->tags;


--Sean
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to