贴代码
from jinja2 import Environment, FileSystemLoader
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
templateLoader = FileSystemLoader(searchpath=BASE_DIR + "/static/templates/html1")
env_files = Environment(loader=templateLoader)
def reader_jiaja2(self)
value = {}
template = env_files.get_template('zh_CN/index.html')
html = template.render(object=values)
return html
# world 渲染方法
def doc_template(self, path, obj, distpath, context=None):
dt = DocxTemplate(path)
dt.render(context={"object": obj})
if context:
jinja_env = jinja2.Environment()
dt.render(context={"object": context}, jinja_env=jinja_env)
dt.save(distpath)