On Fri, Mar 10, 2006 at 11:19:34AM +0100, Christopher Lenz wrote: > I agree that fields should simply return HTML as text. Classic > templates are particularly clumsy for forms. The only thing about > form fields/widgets that should be customizable via templates is > where it gets placed, and where the corresponding label should get > placed (i.e. don't include both in the string). > > I've been hacking away yesterday at "yet another HTML builder" lib > which would probably be useful here: > > http://projects.edgewall.com/trac/attachment/wiki/ChristopherLenz/ > html.py > > Example usage: > > >>> from trac.util import html > >>> values = ['one', 'two', 'three'] > >>> curval = 'two' > >>> select = html.SELECT(name='something')[ > ... [html.OPTION(selected=(val == curval))[val] for val in > values] > ... ] > >>> print select > <select name="something"> > <option>one</option> > <option selected="selected">two</option> > <option>three</option> > </select> > > (indentation and line-breaks in output added here for readability) > > This is intended to be used in the various places in Trac where we > generate little HTML snippets.
This would be very handy. If this could either be compatible with the current field "format", or have a conversion layer, that would be ideal. The trac.ticket.field stuff I have added in workflow is backwards compatibile with the current field format, so it could be just glued together. -- Evolution: Taking care of those too stupid to take care of themselves. _______________________________________________ Trac-dev mailing list [email protected] http://lists.edgewall.com/mailman/listinfo/trac-dev
