Quoting michael <[EMAIL PROTECTED]>:

> Since others are in the mood for RFCing, here's something that I was
> thinking about implementing for myself and I just wanted to know how
> others felt about it as well. 

This has come up many times on the list.  Search the archives for some other
opinions on this subject.

> I was wanting to use Class::DBI to Model my data and H::T to View it. When I
> do this I end up with a lot of code that looks like this

Good choice, CLass::DBI is great at simplifying database access (at the cost of
performance)

In the past I have used the following in my Class::DBI modules to simplify its
use with HTML::Template.

sub hashref {
  my $self = shift;
  my $hashref = {};
  my @cols = @_ ? @_ : $self->columns();
  foreach my $column (@cols) {
    my $value = $self->get($column);
    $hashref->{$column} = "".$value if defined $value;   # Stringify
  }
  return $hashref;
}

That will flatten the Class::DBI object into a hashref.

> And then the accompanying tmpl_vars in the templates. I was thinking about
> using  something similar to the way Template Toolkit handles it where I can
> just specify an object and then have H::T pull the attributes (or methods)
> as needed.

If you know Template Toolkit can already do this, then why not use that?  It
can't be for performance reasons, cause you are also planning to use Class::DBI
which is slower that straight DBI calls.

I don't want to push you away from HTML::Template unnecesarily, but you should
use the right tool for the job regardless of your loyalties to any one
particular solution.

Cheers,

Cees


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to