hmadhi has asked for the wisdom of the Perl Monks concerning the following question:

I am using Rose::DB::Object::Manager (get/iterate methods) to source data from a database and HTML::Template for reporting. The HTML report required a TMPL_LOOP to display entries in a database. My question is how do I create an array reference with the get/iterate methods of RDBOM and pass it to HTML::Template. Thank You

Replies are listed 'Best First'.
Re: Rose::DB and HTML Template
by moritz (Cardinal) on Mar 01, 2011 at 09:56 UTC
    Looking at the documentation of Rose::DB::Object::Manager it seems that the get_$thing methods already return array references.

    But since HTML::Template can't call methods, you have to turn each object into a hash reference first. So for example:

    my $cars = YourClass->get_classes; $cars = [map {; {name => $_->name, manufacturer => $_->manufacturer } +}, @$cars]; $template->param(cars => $cars);

    (I'm not really familiar with RDOM, so take this with a grain of salt).

    Of course it kinda defeats the purpose of an object-relation mapper to first construct objects, and then turn them into dumb hashes...

Re: Rose::DB and HTML Template
by tinita (Parson) on May 29, 2012 at 09:42 UTC
    since both replies mentioned that HTML::Template doesn't do method calls I just wanted to add that HTML::Template::Compiled does, so if you are able to switch (there are some differences though) you might give it a try.
Re: Rose::DB and HTML Template
by siracusa (Friar) on Mar 05, 2011 at 14:28 UTC