unit test templater

This commit is contained in:
Yax 2021-01-03 18:25:19 +01:00
parent b72d495cec
commit 8b38769cfc
2 changed files with 34 additions and 1 deletions

View file

@ -5,12 +5,25 @@ import os
from jinja2 import Environment, FileSystemLoader
from stacosys.conf import config
current_path = os.path.dirname(__file__)
template_path = os.path.abspath(os.path.join(current_path, "../templates"))
env = Environment(loader=FileSystemLoader(template_path))
TEMPLATE_DROP_COMMENT = "drop_comment"
TEMPLATE_APPROVE_COMMENT = "approve_comment"
TEMPLATE_NEW_COMMENT = "new_comment"
def get_template(lang, name):
return env.get_template(lang + "/" + name + ".tpl")
class Templater:
def __init__(self, lang, template_path):
self._env = Environment(loader=FileSystemLoader(template_path))
self._lang = lang
def get_template(self, name):
return self._env.get_template(self._lang + "/" + name + ".tpl")