如何在`structure provider:xxx中动态查找页面模板中的提供者
考虑下面的非工作示例
<div class="portlet-manager-row" tal:repeat="portletId python:range(1,5)">
<div class="porlet-well_manager">
<h2 i18n:translate="portlet-well-a">Portlet Well <b tal:content="portletId" /></h2>
<tal:manager define="managerId string:ColophonPortlets${portletId}">
<span tal:replace="structure provider:managerId" />
</tal:manager>
</div>
</div>provider:部分失败,因为provider:假定输入始终是指向提供程序名称的直接字符串,并且似乎不接受变量。
发布于 2012-03-19 19:25:19
TALES提供程序表达式是字符串表达式的子类,因此您应该能够执行以下操作:
<div class="portlet-manager-row" tal:repeat="portletId python:range(1,5)">
<div class="porlet-well_manager">
<h2 i18n:translate="portlet-well-a">Portlet Well <b tal:content="portletId" /></h2>
<span tal:replace="structure provider:ColophonPortlets$portletId" />
</div>
</div>注意字符串表达式是多余的,我移动并简化了$portletId变量插值;对于更复杂的字符串插值,使用${expression}语法(例如${request/providername})。
https://stackoverflow.com/questions/9766744
复制相似问题