Skip to content

Commit

Permalink
imp: mako files can be imported from poweremail template body
Browse files Browse the repository at this point in the history
  • Loading branch information
lcbautista committed Jul 16, 2024
1 parent 243bb62 commit 9d88b5c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
from osv import osv, fields
from tools.translate import _
from tools.safe_eval import safe_eval
from tools import config
#Try and check the available templating engines
from mako.template import Template #For backward combatibility
try:
from mako.template import Template as MakoTemplate
from mako.lookup import TemplateLookup
from mako import exceptions
TEMPLATE_ENGINES.append(('mako', 'Mako Templates'))
except:
Expand Down Expand Up @@ -193,13 +195,18 @@ def get_value(cursor, user, recid, message=None, template=None, context=None):
'db': cursor.dbname
})
if template.template_language == 'mako':
templ = MakoTemplate(message, input_encoding='utf-8')
addons_lookup = TemplateLookup(
directories=[config['addons_path']], input_encoding='utf-8'
)
templ = MakoTemplate(message, input_encoding='utf-8', lookup=addons_lookup)
extra_render_values = env.get('extra_render_values', {}) or {}
values = {
'object': object,
'peobject': object,
'env': env,
'format_exceptions': True,
'template': template,
'lang': context.get('lang', config.get('default_lang', 'en_US')),
}
values.update(extra_render_values)
reply = templ.render_unicode(**values)
Expand Down

0 comments on commit 9d88b5c

Please sign in to comment.