[htmltmpl] 2 New(?) Ideas
Brought to you by:
samtregar
From: Jason P. <ja...@jo...> - 2004-12-03 20:52:26
|
While I'm thinking about this, what do you guys think about these? 1) Class::DBI Integration I'm just starting to pick up CDBI (I know, I'm late to the party ;)) and it's kind of frustrating to get the data into the template. Or it could be made easier. I'm not sure if we're talking Plugin or an update to the core, but what would be really cool is to accept CDBI objects in the 'associate' parameter: $user_record = CDBI::Subclass->retrieve( $primary_key ); $template = $self->load_tmpl( 'main.TMPL', 'die_on_bad_params' => 0, 'associate' => [ $query, $user_record ], ); Another cool tweak would be to HTML::Template such that you could do a search on the CDBI object and just pass along the results: @results = CDBI::Subclass->search( 'year' => '1980' ); $template->param( 'results' => \@results ); It could be an easy tweak to the code, where if when trying to fill out a <TMPL_VAR NAME="foo"> from the template's internal param hash or from the associated objects' param methods fail, it will try a last-ditch effort of going through associated objects' methods named after the same parameter name (i.e. foo()). These thoughts aren't that well-organized, so I hope you get the jist of what I'm aiming for. I'm mostly hoping to instigate some thoughts on how we can get CDBI better supported in cgiapp & htmltmpl. I know we could add a param() method to the CDBI subclass, but that seems kind of a pain to me. I just dug around the htmltmpl list and found this post[1] that's very similiar to what I'm trying to address. Cees (& another poster) says that he adds something to his CDBI subclass, but again, we could do better by centralizing that same code in the htmltmpl core or a plugin, so we don't have to copy/paste that code in every CDBI subclass we have (and just for one app, I have about 6). Cees also points to Template, but I don't see why we can't also have it in htmltmpl. I'm kinda stuck on htmltmpl, personally -- it's very simple and it keeps me from bleeding logic into the template layer of my applications. 2) Status Messages In an app flow like A -> B -> A, I would like to have a status message on A when B has been successfully processed, but what's the best way to do this? Stuff the message in cgiapp's param? Pass along a param to the runmode method? Then pass that to the template as a param? Cheers, Jason [1]: http://sourceforge.net/mailarchive/message.php?msg_id=8629899 |