Genshi 嵌套匹配模板
如何让 Genshi 解析匹配模板的输出?
换句话说:
我在 Genshi 中有一个这样的模板:
<py:match path="gm:field">
Something ${select('@label')}<br />
${select('*')}
Something else<br />
</py:match>
直接使用时:
<gm:field label="HERE">
<b>Try this!</b>
</gm:field>
完美运行:
Something HERE<br />
<b>Try this!</b>
Something else<br />
但是当我尝试定义另一个委托给它的模板时:
<py:match path="gm:input">
<gm:field label="${select('@label')}">
<input name="${select('@label')}" />
</gm:field>
</py:match>
并调用它:
<gm:input label="x">
<input type="passwd" />
</gm:input>
我在浏览器中看到的结果是:
<gm:field label="x">
<input label="x" />
</gm:field>
而不是:
Something x<br />
<input label="x" />
Something else<br />
我想看到...
我正在使用 Genshi 0.5.1..
Ho do I make Genshi parse the output of a match template?
In other words:
I've got a template like this in Genshi:
<py:match path="gm:field">
Something ${select('@label')}<br />
${select('*')}
Something else<br />
</py:match>
When used directly:
<gm:field label="HERE">
<b>Try this!</b>
</gm:field>
works perfectly:
Something HERE<br />
<b>Try this!</b>
Something else<br />
But when I try to define another one which delegates to it:
<py:match path="gm:input">
<gm:field label="${select('@label')}">
<input name="${select('@label')}" />
</gm:field>
</py:match>
and call it:
<gm:input label="x">
<input type="passwd" />
</gm:input>
The result I see in a browser is:
<gm:field label="x">
<input label="x" />
</gm:field>
instead of:
Something x<br />
<input label="x" />
Something else<br />
which I would like to see...
I am using Genshi 0.5.1..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看源代码后,我认为这是不可能完成的。显然不支持嵌套匹配模板。
After looking into the source code I believe this cannot be done. Apparently nested match templates are not supported.