I have what I thought was a fairly simple problem, but after several days of pondering I can't find a good solution. I have an array the contains a tree. It's a flat array, containing the results of a depth first iteration over the tree. Think find(1) read in to an array. Now each element in the array also contains it's depth, or what level of the tree it's on.

I want to display this array as a indented tree, with each level being indented further from the left. The cleanest way to do this in html/css I feel is to nest containers. Each container has, say, margin-left: 10, then you simply open a new one for each level and you get your nicely indented tree. But that's the problem, how would I accomplish that using the power of HTML::Template? I confess I've got no ideas that don't involve ugly hacks to my data and the template (such as storing a special variable in the array every time it changes level). Anyone got a better idea?

In reply to HTML::Template, pseudo trees and indention. by BUU

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.