开发者

How to render file-based template with arguments?

开发者 https://www.devze.com 2023-03-07 18:39 出处:网络
from mako.template import Template stext = \"hi\" mytemplate = Template(filename=\'./t开发者_StackOverflow社区.txt\')
from mako.template import Template

stext = "hi"

mytemplate = Template(filename='./t开发者_StackOverflow社区.txt')
print mytemplate.render()

t.txt:

${hi}  , i am here


Replace the last line with:

mytemplate.render(hi = "world")

Now, hi can equal anything you like, not just "world".

0

精彩评论

暂无评论...
验证码 换一张
取 消