Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
They actually do neither ... they are templating modules and have no responsibility of producing valid HTML - that's up to the HTML coder. As for being overkill, well ... the more you use these tools, the quicker you get at coding with them. You can see an example that i am proud of over at 4Re: How do I extract text from an HTML page? that uses HTML::Template. The template is stored inside DATA - creating a new H::T object that uses the DATA filehandle is a snap:
my $template = HTML::Template->new(filehandle => \*DATA);
For the Template-Toolkit quick and simple scripts, check out Inline::TT, it's slow as hell, but when you combine it with Class::DBI you get some amazing results. I am nearly finished with my C::D mini-tut that will demonstrate using C::D with multiple tables, but here is a snippet just to show you the power of the Class::DBI and Template combo. (and by the way, i learned most of this from How to Avoid Writing Code and the poop-group mailing list)
use strict; use warnings; use DVD::movie; use Inline 'TT'; print DVD(movies => [DVD::movie->retrieve_all]); __DATA__ __TT__ [% BLOCK DVD %] [% FOREACH movie = movies %] <img src="[% %].jpg" ali +gn="right" /> <h2>[% movie.title %]</h2> <ul> <li> Year - [% movie.year %]</li> <li>Added - [% movie.timestamp %]</li> <li>Directors:</li> <ul> [% FOREACH director = movie.directors %] <li>[% %]</li> [% END %] </ul> <li>Writers:</li> <ul> [% FOREACH writer = movie.writers %] <li>[% %]</li> [% END %] </ul> <li>Genres:</li> <ul> [% FOREACH genre = movie.genres %] <li>[% %]</li> [% END %] </ul> </ul> <br clear="right" /> [% END %] [% END %]
That's just too easy. ;)


(the triplet paradiddle with high-hat)

In reply to 3Re: HTML::Tree(Builder) in 6 minutes by jeffa
in thread HTML::Tree(Builder) in 6 minutes by trs80

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (8)
    As of 2020-11-25 15:22 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found