def generate(self, zone, json_data=None):
# compute local script location to find template_dir
me = os.path.realpath(__file__)
template_dir = os.path.dirname(me) + '/.'
self.d['domain'] = zone
# override with json
if json_data:
self.d.update(json.loads(json_data))
env = Environment(loader=FileSystemLoader(template_dir))
# add to_json filer in jinja2
# so json can be dumped with in jinja2: {{ var | to_json }}
env.filters['to_json'] = json.dumps
template = env.get_template(self.zonetemplate)
json_str = template.render(self.d)
return json_str
gen_template.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录