# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1233322796 -3600 # Node ID bd4e03297cf0bd3494350a9a5655c9874664468f # Parent eee3983e29e9f7b1401f4a745fb14d0e6f88348c function to make generation of a simple sgml tag diff -r eee3983e29e9 -r bd4e03297cf0 common/uilib.py --- a/common/uilib.py Fri Jan 30 14:38:16 2009 +0100 +++ b/common/uilib.py Fri Jan 30 14:39:56 2009 +0100 @@ -4,7 +4,7 @@ contains some functions designed to help implementation of cubicweb user interface :organization: Logilab -:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr """ __docformat__ = "restructuredtext en" @@ -213,6 +213,21 @@ # HTML generation helper functions ############################################ +def simple_sgml_tag(tag, content=None, **attrs): + """generation of a simple sgml tag (eg without children tags) easier + + content and attributes will be escaped + """ + value = u'<%s' % tag + if attrs: + value += u' ' + u' '.join(u'%s="%s"' % (attr, html_escape(unicode(value))) + for attr, value in attrs.items()) + if content: + value += u'>%s' % (html_escape(unicode(content)), tag) + else: + value += u'/>' + return value + def tooltipize(text, tooltip, url=None): """make an HTML tooltip""" url = url or '#'