Add possibility to specify a mako preprocessor #183

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

epegzz commented May 5, 2011

You can now create your own Renderer which uses the default Mako renderer combined with your own preprocessor.
For example you can create a Renderer that understands pyHAML syntax:

  import haml
  from pyramid import mako_templating

  class HamlRenderer(object):
      def __init__(self, info):
          setattr(info, 'preprocessor', haml.preprocessor)
          self.makoRenderer = mako_templating.renderer_factory(info)

      def __call__(self, value, system):
          return self.makoRenderer(value, system)

And then in YOURPROJECT/init.py you can tell pyramid to use your brand new Haml-Renderer for all mako templates:

    config.add_renderer(".mako", HamlRenderer)
@epegzz epegzz Add possibility to specify a mako preprocessor
You can now create your own Renderer which uses the default Mako renderer combined with your own preprocessor.
For example you can create a Renderer that understands pyHAML syntax:

  import haml
  from pyramid import mako_templating

  class HamlRenderer(object):
      def __init__(self, info):
          setattr(info, 'preprocessor', haml.preprocessor)
          self.makoRenderer = mako_templating.renderer_factory(info)

      def __call__(self, value, system):
          return self.makoRenderer(value, system)

And then in YOURPROJECT/__init__.py you can tell pyramid to use your brand new Haml-Renderer for all mako templates:

    config.add_renderer(".mako", HamlRenderer)
f34e7ab

mcdonc closed this in 8bd6cf2 Jun 26, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment