metal:use-macro和metal:在五个ViewPageTemplateFile中定义宏

Mik*_*maa 6 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>
Run Code Online (Sandbox Code Playgroud)

但是,这里没有定义(因为它是旧的独立页面模板的做法,据我所知).

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

Dav*_*ick 7

我想你想要:

<metal:macro use-macro="template/macros/row" />
Run Code Online (Sandbox Code Playgroud)