【发布时间】:2011-01-20 07:02:40
【问题描述】:
我正在使用 App Engine 的网络应用模板系统(与 django 类似但不完全相同)
通常我将静态目录 /templates/ 中的模板渲染为 跟随在我的主处理程序中:
dirname = os.path.dirname(__file__)
template_file = os.path.join(dirname, os.path.join('templates', template_name))
output = template.render(template_file,template_values)
self.response.out.write(output)
对于我当前的应用程序,我想呈现一个包含在 细绳。我正在使用以下代码:
t = template.Template(template_string)
c = template.Context(template_values)
output = t.render(c)
self.response.out.write(output)
它呈现模板,但不呈现其中包含的“包含”标签 字符串。例如字符串模板
“你好世界 {% 包括 'helloworld.html' %}”
呈现“hello world”,但不呈现 'helloworld.html'。 我猜这与字符串不存在有关 在与“helloworld.html”相同的目录中,但我不知道如何 指定包含标签应该在 '/templates/*' 任何帮助,将不胜感激, 阿琼
【问题讨论】:
标签: python django google-app-engine django-templates