Re: [htmltmpl] RFC: Objects in templates
Brought to you by:
samtregar
From: Timm M. <tm...@ag...> - 2004-06-02 16:10:55
|
I've seen ideas like this suggested many times before, and it should be done. Just needs someone to sit down and write the code :) At 10:29 AM 6/2/04 -0500, michael wrote: >Since others are in the mood for RFCing, here's something that I was thinking >about implementing for myself and I just wanted to know how others felt about >it as well. > >I was wanting to use Class::DBI to Model my data and H::T to View it. When I >do this I end up with a lot of code that looks like this > >$tmpl->param( > ObjAtt1 => $obj->att1, > ObjAtt2 => $obj->att2, > ObjAtt3 => $obj->att3, > ObjAtt4 => $obj->att4, > ObjAtt5 => $obj->att5, > ); > >And then the accompanying tmpl_vars in the templates. I was thinking about >using something similar to the way Template Toolkit handles it where I can >just specify an object and then have H::T pull the attributes (or methods) as >needed. Something like this... > >$tmpl->param(Obj => $obj); > >and then in the template have > ><tmpl_var name="Obj->att1"> <tmpl_var name="Obj->att2">... etc > >or something like it. I think it should also allow the user to specify what >token will be used to separate objects and methods (ie, change '->' to just >'.' like in Perl6). I think some mechanism should also be given so that you >can loop around objects as well (an array of objects). > >so that >$tmpl->param(Obj_loop => \@array_of_objs); > >would work for ><tmpl_loop Obj_loop> > <tmpl_var Obj->att1> <tmpl_var Obj->att2> ></tmpl_loop> > >If there are serious reasons for not including this in standard H::T tags then >maybe some new tags like TMPL_OBJ_VAR and TMPL_OBJ_LOOP. > >Questions, comments, verbal abuse welcome. > >Michael Peters > > > >------------------------------------------------------- >This SF.Net email is sponsored by the new InstallShield X. > From Windows to Linux, servers to mobile, InstallShield X is the one >installation-authoring solution that does it all. Learn more and >evaluate today! http://www.installshield.com/Dev2Dev/0504 >_______________________________________________ >Html-template-users mailing list >Htm...@li... >https://lists.sourceforge.net/lists/listinfo/html-template-users |