Edgewall Software

Ticket #130: loader_callback.diff

File loader_callback.diff, 2.0 KB (added by cmlenz, 8 years ago)

More comprehensive patch

  • doc/plugin.txt

    191191.. _`Understanding HTML, XML and XHTML`: http://webkit.org/blog/?p=68
     195The callback function that should be invoked whenever the template loader loads
     196a new template. Unlike the other options, this option can **not** be passed as
     197a string value, but rather must be a reference to the actual function. That
     198means it can not be loaded from non-Python configuration files.
    195202The error handling style to use in template expressions. Can be either
  • genshi/template/plugin.py

    5858            raise ConfigurationError('Invalid value for max_cache_size: "%s"' %
    5959                                     options.get('genshi.max_cache_size'))
     61        loader_callback = options.get('genshi.loader_callback', None)
     62        if loader_callback and not callable(loader_callback):
     63            raise ConfigurationError('loader callback must be a function')
    6165        lookup_errors = options.get('genshi.lookup_errors', 'lenient')
    6266        if lookup_errors not in ('lenient', 'strict'):
    6367            raise ConfigurationError('Unknown lookup errors mode "%s"' %
    6771                                     auto_reload=auto_reload,
    6872                                     max_cache_size=max_cache_size,
    6973                                     default_class=self.template_class,
    70                                      variable_lookup=lookup_errors)
     74                                     variable_lookup=lookup_errors,
     75                                     callback=loader_callback)
    7277    def load_template(self, templatename, template_string=None):
    7378        """Find a template specified in python 'dot' notation, or load one from