Genshi布局包括Chameleon ZPT
在Genshi中,你可以包括布局(对我而言,这是确保所有500个内容模板具有相同布局的唯一方法) -
"""layout.xml"""
<py:match path="head" once="true">
<head py:attrs="select('@*')">
<title>Myapp</title>
</head>
</py:match>
<py:match path="body" once="true">
<body py:attrs="select('@*')">
<div class="main_content">
<div py:strip="True">${select('*|text()')}</div>
</div>
</body>
</py:match>
"""layout.xml"""
"""index.xml"""
<html xmlns:py="http://genshi.edgewall.org/" xmlns:xi="http://
www.w3.org/2001/XInclude">
<xi:include href="layout.xml" parse="xml"/>
<head />
<body>
<h3>index</h3>
</body>
</html>
"""index.xml"""
"""rendered index.html"""
<html>
<head>
<title>Myapp</title>
</head>
<body>
<div class="main_content">
<h3>index</h3>
</div>
</body>
</html>
"""rendered index.html"""
Chameleon ZPT有可能吗?顺便说一句,几个星期前我曾尝试过Chameleon-genshi,但它仍然因生产过于烦躁。
谢谢。
没有找到相关结果
已邀请:
1 个回复
催备南菠亨
index.pt
这使:
我刚开始使用Chameleon ZPT,所以如果有人能指出我的例子中的任何缺陷我会很感激:)