Skip to content

Instantly share code, notes, and snippets.

@tomchristie
Created September 21, 2011 07:52
Show Gist options
  • Save tomchristie/1231497 to your computer and use it in GitHub Desktop.
Save tomchristie/1231497 to your computer and use it in GitHub Desktop.
Better API on DocumentingTemplateRenderer for escaping content.
class DocumentingTemplateRenderer(BaseRenderer):
...
escape_binary = True
def _escape_binary(content):
if self.escape_binary and not all(char in string.printable for char in content):
return '[%d bytes of binary content]' % len(content)
return content
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment