package HTML::Template::Documentation; use base qw( HTML::Template ); use strict; #use warnings; #use diagnostics; sub documentation { my $self = shift; my $template = __PACKAGE__->new( filehandle => *main::DATA ); $template->param( title => $self->{ options }->{ filepath } || 'HT +ML::Template' ); my $content = { VAR => [], LOOP => [] }; for my $param ( sort { $self->query( name => $b ) cmp $self->query( name => $a ) || $a cmp $b } $self->param ) { my $type = $self->query( name => $param ); push @{ $content->{ $type } }, +{ name => $param } if $type eq + 'VAR'; $self->_query_loops( $content->{ LOOP }, $param, 2 ) if $type +eq 'LOOP'; } $template->param( %$content ); return $template->output; } sub _query_loops { my( $self, $loops, $name, $level, $chain ) = @_; my @path = $name; unshift @path, @$chain if $chain; push @{ $loops }, +{ name => $name, level => $level, VAR => [] }; for my $param ( sort { $self->query( name => [ @path, $b ] ) cmp $self->query( name => [ @path, $a ] ) || $a cmp $b } $self->query( loop => \@path ) ) { my $type = $self->query( name => [ @path, $param ] ); push @{ $loops->[ $#{ $loops } ]->{ $type } }, { name => $para +m } if $type eq 'VAR'; $self->_query_loops( $loops, $param, $level + 1, \@path ) if $ +type eq 'LOOP'; } } package main; print HTML::Template::Documentation->new( filename => shift )->documen +tation; __DATA__ =head1 NAME <!-- TMPL_VAR NAME="title" --> - Template Documentation =head1 DESCRIPTION The following is auto-generated documention for the supplied HTML::Tem +plate data. =head1 VARIABLES <!-- TMPL_IF NAME="var" --> =over 4 <!-- TMPL_LOOP NAME="var" --> =item * <!-- TMPL_VAR NAME="name" --> <!-- /TMPL_LOOP --> =back <!-- /TMPL_IF --> =head1 LOOPS <!-- TMPL_IF NAME="loop" --> <!-- TMPL_LOOP NAME="loop" --> =head<!-- TMPL_VAR NAME="level" --> <!-- TMPL_VAR NAME="name" --> <!-- TMPL_IF NAME="var" --> =over 4 <!-- TMPL_LOOP NAME="var" --> =item * <!-- TMPL_VAR NAME="name" --> <!-- /TMPL_LOOP --> =back <!-- /TMPL_IF --> <!-- /TMPL_LOOP --> <!-- /TMPL_IF -->

In reply to tmpldoc.pl - generate documentation for HTML::Template templates by LTjake

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.