[Dbix-class] Using DBIx::Class with HTML::Template - anyone doing it?

Ash Berlin ash at cpan.org
Tue Oct 31 16:55:02 GMT 2006


Kevin Old wrote:
> 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;
> }
> 

Not sure if thats a transposition error,

but dont you want:

if ( \@stories ) {
    $tmpl->param( stories => \@stories );
    print $tmpl->output;
}

Anyway, take a look at the Cookbook, near the end there is a way to 
inflate to a hashref, which would do what you want in this case I 
suspect. Currently you'll have to write it yourself like in the 
cookbook, but by next release it will be part of the dist.


Ash



More information about the DBIx-Class mailing list