[Catalyst] Modifying a value returned with DBIC

Ash Berlin ash_cpan at firemirror.com
Fri Jan 5 09:58:59 GMT 2007


Octavian Rasnita wrote:
> Hi,
> 
> I want to get some messages from a database using DBIx::Class, then to 
> pass them to TT, but I also want to make some preformatting before 
> sending to TT.
> (I don't know if TT can do what I want).
> 
> I did:
> 
> @messages = $c->model("Db::Forum")->search({
> id_room => $id_room,
> },
> {
> join => "id_user",
> prefetch => "id_user",
> rows => $c->user->nr_messages || 10,
> order_by => 'date desc, time desc',
> });
> 
> $c->stash->{messages} = \@messages;
> 
> But I want to replace \n in the body of the messages with <br />, and 
> who knows, maybe other such format changes.
> 
> Which is the recommended way of doing this?
> Should I loop @messages in the program, get each value, modify it and 
> store it into another array then send it to TT, or there is another more 
> elegant method?
> 
> Thank you.
> 
> Octavian

Look at TT's Filters - chances are it will have one to do what you want.

Ash



More information about the Catalyst mailing list