This commit is contained in:
Magnun Leno 2014-06-24 14:45:16 +00:00
commit 0ff0ee2c94
2 changed files with 19 additions and 0 deletions

View file

@ -2,6 +2,7 @@
from __future__ import unicode_literals, print_function
import os
import imp
import math
import random
import logging
@ -65,6 +66,15 @@ class Generator(object):
]),
extensions=self.settings['JINJA_EXTENSIONS'],
)
try:
theme_functions = imp.load_source('theme_functions',
os.path.join(self.theme, '/functions.py'))
except IOError:
theme_functions = None
if theme_functions and hasattr(theme_functions, '__export__'):
for func_name in theme_functions.__export__:
self.env.globals[func_name] = getattr(theme_functions, func_name)
logger.debug('template list: {0}'.format(self.env.list_templates()))

View file

@ -0,0 +1,9 @@
# encoding: utf-8
__export__ = ["helperFunction"]
def helperFunction():
return "<p>I'm from a helper function!</p>"
def anotherHelper():
return "I'm not being exported!"