Mike, take a look at Breve template engine<http://breve.twisty-industries.com/>. It does pretty much what you want.
On Tuesday, December 10, 2013 4:20:34 AM UTC-4, Mike Orr wrote: > > Would you like class-based tag helpers to compose an HTML tag > imperatively over several statements? If so, what API would you like? > I looked around for precedents but didn't find any. I've been playing > around with something like this. > > class Tag(list): > - 'name' is positional arg (the tag name). > - elements are children. (text and/or subtags) > - .attrs is a dict of attributes. > - .__html__() returns a literal. > > class UL(list): > - elements are children. (will be converted to <li>'s on render) > - .attrs is a dict of attributes for the <ul> tag. > . .li_attrs is a dict of attributes for the <li> tags. > - This doesn't allow some <li> tags to have different attributes > than others. This matters if you want to mark one as class="active" > (i.e., the current one). I can't think of how to do this without > overriding list.append() and introducing some complex structure. Or > converting the elements to Tag's immediately, but that loses the > advantage of the elements being just the <li>'s content. > > > class Select(list): > - Same concept but elements are options. > - .group() -> make an option group which can contain options. > > class Link(object): > - .text and .url attributes, and perhaps .attrs. > - should the text be called text, content, title, or label? All of > these have other meanings in HTML, except 'content', but 'content' > implies something larger than just a short phrase. > > -- > Mike Orr <[email protected] <javascript:>> > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/groups/opt_out.
