Back to index

plone3  3.1.7
Classes | Functions | Variables
plone.memoize.compress Namespace Reference


class  XHTMLSlimmer


def xhtml_compress


tuple xhtmlslimmer = XHTMLSlimmer()

Detailed Description

In order to use Peter Bengtsson's slimmer library available from
you need to register the XHTMLSlimmer utility like this:

  <utility component="plone.memoize.compress.xhtmlslimmer"
           provides="plone.memoize.interfaces.IXHTMLCompressor" />

You can register other XHTML-whitespace removal libraries as well.

Per default there is no compressor available and we get the same string back:

   >>> html_string = u"<html><body><SPAN>Hello.</SPAN></body><html>"
   >>> xhtml_compress(html_string) is html_string

Make a stupid lowercasing compressor. This is not safe as it would lowercase
all text outside of tags as well:

   >>> class LowerCaser(object):
   ...     implements(IXHTMLCompressor)
   ...     def compress(self, string):
   ...         return string.lower()

   >>> lower = LowerCaser()

Register our new compressor:

   >>> from zope.component import getSiteManager
   >>> sm = getSiteManager()
   >>> sm.registerUtility(lower)

   >>> xhtml_compress(html_string)

Function Documentation

Definition at line 50 of file

00051 def xhtml_compress(string):
00052     util = queryUtility(IXHTMLCompressor)
00053     if util is not None:
00054         return util.compress(string)
00055     return string

Here is the caller graph for this function:

Variable Documentation

Definition at line 43 of file

Definition at line 66 of file