# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1235747793 -3600 # Node ID 59552ba2015fce1b0b05b51db05bcd07110b902b # Parent 01f5001304b2aec54bd02c88e8fc0bba3aeb2168 more tags, map klass -> class avoiding needs to use **dict diff -r 01f5001304b2 -r 59552ba2015f common/tags.py --- a/common/tags.py Tue Feb 24 17:20:04 2009 +0100 +++ b/common/tags.py Fri Feb 27 16:16:33 2009 +0100 @@ -1,5 +1,13 @@ -from logilab.mtconverter import html_escape +"""helper classes to generate simple (X)HTML tags + +:organization: Logilab +:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr +""" +__docformat__ = "restructuredtext en" + from cubicweb.common.uilib import simple_sgml_tag + class tag(object): def __init__(self, name): self.name = name @@ -14,6 +22,11 @@ img = tag('img') label = tag('label') option = tag('option') +h1 = tag('h1') +h2 = tag('h2') +h3 = tag('h3') +h4 = tag('h4') +h5 = tag('h5') def select(name, id=None, multiple=False, options=[]): attrs = {} @@ -21,8 +34,8 @@ attrs['multiple'] = 'multiple' if id: attrs['id'] = id - html = [u'' % ( + name, ' '.join('%s="%s"' % kv for kv in attrs.items()))] html += options html.append(u'') return u'\n'.join(html) diff -r 01f5001304b2 -r 59552ba2015f common/uilib.py --- a/common/uilib.py Tue Feb 24 17:20:04 2009 +0100 +++ b/common/uilib.py Fri Feb 27 16:16:33 2009 +0100 @@ -209,6 +209,10 @@ """ value = u'<%s' % tag if attrs: + try: + attrs['class'] = attrs.pop('klass') + except KeyError: + pass value += u' ' + u' '.join(u'%s="%s"' % (attr, html_escape(unicode(value))) for attr, value in attrs.items() if value is not None)