Python模板帮助
我正在使用AppEngine的web应用程序模板系统(如果与django不同,则类似) 通常我从静态目录/templates/as呈现模板 在我的主处理程序中如下所示:Python模板帮助,python,django,google-app-engine,django-templates,Python,Django,Google App Engine,Django Templates,我正在使用AppEngine的web应用程序模板系统(如果与django不同,则类似) 通常我从静态目录/templates/as呈现模板 在我的主处理程序中如下所示: dirname = os.path.dirname(__file__) template_file = os.path.join(dirname, os.path.join('templates', template_name)) output = template.render(template_file,template
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)
它呈现模板,但不呈现其中包含的“include”标记
绳子。例如,字符串模板
“你好世界{%include'helloworld.html%}”
呈现“hello world”,但不呈现
“helloworld.html”。
我猜这与字符串没有被激活有关
在与“helloworld.html”相同的目录中,但我不知道如何
指定include标记应在“/templates/*”中查找
任何帮助都将不胜感激,
阿琼
应该有用
应该有用 webapp框架使用Django 0.9.6模板。如果像上面描述的那样从字符串加载模板,则需要这样做,以便它可以找到从文件加载的依赖项。webapp如何配置它们。webapp框架使用Django 0.9.6模板。如果像上面描述的那样从字符串加载模板,则需要这样做,以便它可以找到从文件加载的依赖项。webapp如何配置它们
{% include 'dirname/helloworld.html' %}