Re: HTML::Template with simplified/automated fill in from database.

Mathew Robertson <[email protected]> Mon, 25 Feb 2008 10:39:07 +1100
Newsgroups gmane.comp.lang.perl.modules.html-template
Organization Nielsen//NetRatings
Message-ID <[email protected]>
Hi Ronald,

>>> I am looking to generate easy visualizations of
>>>  objects serialized in a database USING the underlying model.    
>> It sounds like you're talking about a glue between "model" components
>> like dbix::class, class::dbi, etc?
>>     
> Close.  Yes a glue layer between HTML::Template and a database.  I 
> could try to use some of these higher layer abstractions (including 
> Rose:DB) or use a modern DBI layer with its 
> primay_key/primary_key_info/foreign_key_info functions ...
Based on your example below, are you thinking of something like 
Template::Plugin::DBI (as used in Template::Toolkit)?  ie: see examples 
here:
http://search.cpan.org/~abw/Template-DBI-2.64/lib/Template/Plugin/DBI.pm

Alternatively, have you looked at HTML::FillInForm?

>   <html>
>   <head><title>Test Template</title>
>   <body>
>   <TMPL_LOOP NAME="+books">
>     <ul>
>         <li />Title is "<TMPL_VAR NAME=".title">"
>         <li />ISBN is <TMPL_VAR NAME=".isbn">
>         <li />Authors are:
>         <ul>
>             <!-- name below is shorthand for +books.book_id.authors -->
>             <!-- could still be abbreviated to +authors if fk's link 
> tables --> 
>         <TMPL_LOOP NAME=".book_id.authors:ORDER_BY:.last_name,.first_name" >
>             <li /><TMPL_VAR NAME=".last_name">, <TMPL_VAR 
> NAME=".first_name">
>         </TMPL_LOOP>
>         </ul>
>     </ul>
>   </TMPL_LOOP>   
>   </body>
>   </html>
If so, (IMO) H::T wasn't designed to be pluggable/extensible in that 
way.  However, that hasn't stopped a number of users extending/modifying 
the H::T codebase in various ways, ie: I use a version which allows me 
to subclass H::T (or H::T::E) so that I can extend the tag syntax.  From 
memory, I think someone else on this list has hooked together H::T and 
HTML::FillInForm.

In your example above, I would subclass H::T to handle the following (or 
something similar):

   ...
   <TMPL_SQL_LOOP NAME="books">
        ...<TMPL_FIELD NAME="title">
        ...<TMPL_SQL_LOOP NAME="authors" WHERE="book_id = books.book_id" 
ORDER_BY="last_name, first_name">
             ...<TMPL_FIELD last_name>...
        ...</TMPL_SQL_LOOP>
   </TMPL_SQL_LOOP>
   ...

cheers,
Mathew

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users