[Dbix-class] Using DBIx::Class with HTML::Template - anyone doing
it?
Kevin Old
kevinold at gmail.com
Tue Oct 31 16:30:50 GMT 2006
Hello everyone,
I'm trying to use DBIx::Class with HTML::Template and I can't seem to
get it to work.
Here's how I'm calling DBIC and HTML::Template in my script:
my $tmpl = HTML::Template->new( filename => "single_stories.tmpl",
die_on_bad_params => 1);
my @stories = $schema->resultset('Stories')->search( { user_id => 1234 } )->all;
if ( $stories ) {
$tmpl->param( stories => $stories );
print $tmpl->output;
}
Here's my single_stories.tmpl:
<TMPL_IF NAME="stories">
<TMPL_LOOP NAME="stories">
<TMPL_VAR NAME="story_id">
</TMPL_LOOP>
</TMPL_IF>
If I do this with my script, I'm able to get the data passed correctly
to HTML::Template:
if ($stories) {
my @sts;
while ( my $st = $stories->next ) {
push @sts, { story_id => $st->story_id };
}
$tmpl->param( stories => \@sts );
print $tmpl->output;
}
Basically, I make an array of anonymous hashes with the data in it.
Anyway to do this with DBIC without having to cycle build the AoH?
Thanks for any help,
Kevin
--
Kevin Old
kevinold at gmail.com
More information about the DBIx-Class
mailing list