Cheetah模板引擎3 -- Template对象构造

Cheetah模板引擎3 -- Template对象构造
1. Template对象构造

Template对象有7种构造方法, 分别如下:
* 直接使用字符串
t = Template("The king is a $placeholder1.")
Pass the template definition as a string.
          * 使用模板文件
t = Template(file="fink.tmpl")
Read the template definition from a file named "fink.tmpl".
          *使用文件对象
t = Template(file=f)
Read the template definition from file-like object 'f'.
          *重载方法,加入填入信息
t = Template("The king is a $placeholder1.", searchList=[dict, obj])

t = Template(file="fink.txt", searchList=[dict, obj])

t = Template(file=f, searchList=[dict, obj])



你可能感兴趣的:(Cheetah模板引擎3 -- Template对象构造)