From my understanding it boils down to  $DB->($query, $mask) Where query is sql and mask is a template, and $DB is a function that basically does
my $sth = $dbh->prepare($query); $sth->execute; $out = ''; foreach my $queryResult( $sth->fetchrow_hashref ) $out .= $mask->process( $queryResult ) } return $out;
Except he chose delimiters to be different and significant -- which is why he had to use regular expressions to parse his xml-ish balanced tags, instead of using XML::Twig or HTML::Seamstress

To do the same in TT2, you create a template DB which uses Template::Plugin::DBI so you can write

<table width="50%"> [% MACRO mask BLOCK %] <tr> <td> [% news_title %] </td> <td> [% news_headline %] </td> <td>[% WRAPPER link action = "readnews" newsitem = news_id %]Read More...[% END # block test %] </td> </tr> [% END # macro block mask %] [% INCLUDE DB ## db calls macro mask, can be redefined query=' SELECT * FROM latestnews; ' %] </table>
query is a variable, mask is macro ( a template ) , and the template DB calls the macro mask, after defining variables based on database column names (presumably news_id, news_title, news_headline ) to populate mask

This works out of the box with TT2.

Sure, you have to define the MACRO mask before INCLUDE-ing the template DB, but that could be remedied by expanding the syntax so you can assign macros to a variable, or it could be implemented as a Template::Plugin or Template::View -- not a lot of work


In reply to Re^4: RFC : Abstraction Markup by Anonymous Monk
in thread RFC : Abstraction Markup by simonodell

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.