plone - 金属:use-macro and metal:define-macro within Five ViewPageTemplateFile

标签 plone

我想在单个“五个ViewPageTemplateFile”页面模板中使用一个宏,以避免将代码粘贴到周围。

以下是我的尝试:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      tal:omit-tag=""
      >

    <metal:row define-macro="row">
        <tal:block repeat="widget view/widgets">
            <div tal:attributes="class python:'%s%s' % (widget.klass, widget.mode=='hidden' and ' hidden' or '')"
                 tal:condition="python:view._includeRow(widget.name)">

                <div tal:replace="structure widget/render"></div>

            </div>
        </tal:block>
    </metal:row>

    <table class="datagridwidget-table-view" tal:attributes="data-extra view/extra">
        <thead>
            <tr>
                <th class="header">
                    <!-- -->
                </th>
                <th id="" class="header" tal:condition="view/allow_insert"></th>
                <th id="" class="header" tal:condition="view/allow_delete"></th>
                <th id="" class="header" tal:condition="view/allow_reorder"></th>
                <th id="" class="header" tal:condition="view/allow_reorder"></th>
            </tr>
        </thead>
        <tbody class="datagridwidget-body" tal:attributes="data-name_prefix view/name_prefix; data-id_prefix view/id_prefix">
            <tal:row repeat="widget view/getNormalRows">
                <tr>
                    <metal:macro use-macro="here/row" />
                </tr>
            </tal:row>

            <tal:row condition="view/getTTRow" define="widget view/getTTRow">
                <tr>
                    <metal:macro use-macro="here/row" />
                </tr>
            </tal:row>


            <tal:row condition="view/getAARow" define="widget view/getAARow">
                <tr>
                    <metal:macro use-macro="here/row" />
                </tr>
            </tal:row>


    </tbody>
</table>
<input type="hidden" tal:replace="structure view/counterMarker" />
</html>

但是,此处未定义(据我所知,这是旧的独立页面模板的处理方式)。

如何从ViewPageTemplate .pt模板引用模板本身,并在.pt文件中使用/定义宏?

最佳答案

我想你要:

<metal:macro use-macro="template/macros/row" />

关于plone - 金属:use-macro and metal:define-macro within Five ViewPageTemplateFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13165748/

相关文章:

python - 为什么plone.api没有find?

plone - 在 Plone build设置中查找需求规范

python - 以编程方式在 plone 上创建内容类型时,time.time() 是一种安全的方法吗?

python - 使用 createContentInContainer 创建内容

ubuntu - 每天一次同步运行 Ubuntu 的整个 Plone 生产服务器的可行性

plone - 如何为 z3cform 创建一个新的 contenttreewidget

encoding - Zope 2 编码/解码 request.form.items 的位置

overriding - 使用z3c.jbot覆盖Plone document_view

python - 自动粘贴创建 -t plone3_buildout

plone - 如何将资源注册表资源迁移到 Plone 5