2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
6 """I hold HTML generation helpers.
9 from twisted.python import log
11 from twisted.web import resource
13 import traceback, string
15 from cStringIO import StringIO
16 from microdom import escape
19 "Wrap <pre> tags around some text and HTML-escape it."
20 return "<pre>"+escape(text)+"</pre>"
26 io.write("<li> %s</li>\n" % el)
34 io.write('<li> <a href="%s">%s</a></li>\n' % (hr, el))
38 def output(func, *args, **kw):
39 """output(func, *args, **kw) -> html string
40 Either return the result of a function (which presumably returns an
41 HTML-legal string) or a sparse HTMLized error message and a message
45 return func(*args, **kw)
47 log.msg("Error calling %r:" % (func,))
49 return PRE("An error occurred.")