I've looked on and off at Breve. Three problems with it though: it
would add a dependency to a whole template language, in applications
which are likely using another template language and maybe aren't even
using the HTML submodule at all. It seems to resolve expressions to
HTML immediately whereas sometimes you want an object to build up
incrementally, And it looks like you have to put templates in a *.b
file rather than directly in your Python code.

I've got a UL class running in an application.

lxml.objectify has a cumbersome syntax for what I'm looking for, and
lxml would also be a large dependency. 'markup' seems to be old: it
only goes up to HTML 4.01. There are some others on PyPI but they're
also old.



On Tue, Dec 31, 2013 at 10:38 AM, askel <[email protected]> wrote:
> Mike, take a look at Breve template engine. 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]>
>
> --
> 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.



-- 
Mike Orr <[email protected]>

-- 
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.

Reply via email to