如何在 Chameleon 中使用模板继承? [英] How to use template inheritance with Chameleon?
本文介绍了如何在 Chameleon 中使用模板继承?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用最新的 Pyramid 来构建网络应用程序.不知何故,我们已经开始使用 Chameleon 作为模板引擎.我以前使用过 Mako,创建一个基本模板非常简单.变色龙也可以这样吗?
我试图浏览文档,但似乎找不到简单的解决方案.
解决方案
在 Chameleon >= 2.7.0 中,您可以使用加载"TALES 表达式.示例:
main.pt:
<头><div metal:define-slot="head"></div>头部><身体><ul id="菜单"><li><a href="">项目 1</a></li><li><a href="">项目 2</a></li><li><a href="">项目 3</a></li><div metal:define-slot="content"></div></html>
my_view.pt:
<div metal:fill-slot="content"><p>卓悦吹捧世界.</p>
</html>
I am using latest Pyramid to build a web app. Somehow we have started using Chameleon as the template engine. I have used Mako before and it was extremely simple to create a base template. Is this possible with chameleon as well?
I have tried to look through the docs but I can not seem to find an easy solution.
解决方案
With Chameleon >= 2.7.0 you can use the "load" TALES expression. Example:
main.pt:
<html>
<head>
<div metal:define-slot="head"></div>
</head>
<body>
<ul id="menu">
<li><a href="">Item 1</a></li>
<li><a href="">Item 2</a></li>
<li><a href="">Item 3</a></li>
</ul>
<div metal:define-slot="content"></div>
</body>
</html>
my_view.pt:
<html metal:use-macro="load: main.pt">
<div metal:fill-slot="content">
<p>Bonjour tout le monde.</p>
</div>
</html>
这篇关于如何在 Chameleon 中使用模板继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文