Skip to content

Instantly share code, notes, and snippets.

@tao4yu
Created December 26, 2013 07:18
Show Gist options
  • Save tao4yu/8130796 to your computer and use it in GitHub Desktop.
Save tao4yu/8130796 to your computer and use it in GitHub Desktop.
Jinja2 startup 入门
from jinja2 import Environment, FileSystemLoader
import os
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
env = Environment(loader=FileSystemLoader(CURRENT_DIR), trim_blocks=True)
template = env.get_template("template.xml")
# 利用数据(字典数据文件或 key-value对)渲染模板
print template.render(taskData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment