Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use a class, so we can implement a translate function

  • Loading branch information...
commit 5f9220082440e375a24ca7523b4639a99acf45bd 1 parent 5348368
@mcdonc authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 deform_mako/__init__.py
View
15 deform_mako/__init__.py
@@ -1,10 +1,13 @@
import os
from mako.template import Template
-def mako_renderer_factory(directory, translator=None):
- def mako_renderer(tname, **kw):
- filename = os.path.join(directory, tname) + '.mako'
- template = Template(filename=filename)
- return template.render(_=translator, **kw)
- return mako_renderer
+class mako_renderer_factory(object):
+ def __init__(self, directory, translator=None):
+ self.directory = directory
+ self.translate = translator
+ def __call__(self, tname, **kw):
+ filename = os.path.join(self.directory, tname) + '.mako'
+ template = Template(filename=filename)
+ return template.render(_=self.translate, **kw)
+
Please sign in to comment.
Something went wrong with that request. Please try again.