HTML::Template in and of it's self does not allow for recursion. However, recently when I was attempting solve a problem similar to this, what I did was write a template that *allowed* for recursion and then used the perl code to actually recurse. In other words, my template looked something like this:
<div> <tmpl_var one> <tmpl_var two> <tmpl_var recursion_data> </div>
Then in my perl code I did something similar to:
my $ht=new HTML::Template(filename=>recurse.tmpl); my $data; while($foo=recurse()) { $ht->param(one=>foo,two=>bar, recursion_data=>$data); $data=$ht->output; $ht->clear_params(); }
Thus the total output is constantly updated with all the data you have generated so far, then you stick that data inside the template and do it again. Seemed rather elegant to me at the time, but this may not at all be what you are considering.

(Btw, if in fact you are doing something similar to what I think you, some sort of nested tree structure and your trying to indent each layer, appropiate, what I did was make each <div></div> in my recursion template have a padding of 5 pixels left or whatever. That way when I nest all of the divs, each one inherits the padding value of all of it's parents, so the first layer had 5 px, the second layer had 10 and so on and so forth. Thus combining the beauty of HTML::Template with the simplicity that is CSS. There are several benefits to doing it this way, such as it's incredibly easy to change the padding for each layer, just change one value in the style sheet, instead of mucking about with perl code.)

In reply to Re: can you repeat a character N times using HTML::Template? by BUU
in thread can you repeat a character N times using HTML::Template? by spditner

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.