~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/util.py

  • Committer: William Grant
  • Date: 2011-03-23 03:59:38 UTC
  • mto: This revision was merged to the branch mainline in revision 442.
  • Revision ID: william.grant@canonical.com-20110323035938-rch2qg5l7wro3dv2
add html_format, taking a format string and escaping arguments as they are inserted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
    return "".join(html_entity_map.get(c, c) for c in s)
232
232
 
233
233
 
 
234
def html_format(template, *args):
 
235
    """Safely format an HTML template string, escaping the arguments."""
 
236
    return template % tuple(html_escape(arg) for arg in args)
 
237
 
 
238
 
234
239
# FIXME: get rid of this method; use fixed_width() and avoid XML().
235
240
 
236
241
def html_clean(s):