When dealing with HTML::Template, Template toolkit, or other such templating modules, you must separate what you're doing into two (mostly) unrelated things - the data structure you generate and the template that accepts that data structure.

I would recommend doing the following:

  1. Examine what you're doing and figure out what items/groups of items are similar. Those are candidates for looping.
  2. Figure out what items/groups of items can change between invocations of your page. (Things like date, username, colors, etc.)
  3. Create a data structure that encapsulates how the programmer thinks of the output.
  4. Then, and only then, create a template that will take that data structure and display it appropriately.

If you follow that method, you're aren't tied to a given templating module. :-)

Now, C::A has nothing to do with H::T. Yeah, it uses it by default (and most C::A users also use H::T), but they are solving two completely unrelated problems. (I use H::T to templatize Apache config files that never see the WWW.) C::A is meant to simplify how pages in your application relate to each other. It sounds like you're understanding that (for the most part), but you're having issues with H::T and how to build with/for it.

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


In reply to Re: Creating reports with HTML::Template and CGI::Application by dragonchild
in thread Creating reports with HTML::Template and CGI::Application by bar10der

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.