Trouble repeating elements using TAL, Chameleon and Pyramid

时光毁灭记忆、已成空白 提交于 2019-12-07 22:42:25

Weird. I think this should work.

Anyway, your use of tal:replace here is wrong as it's gonna replace the whole tag. What you want is to replace the contents of the tag with tal:content:

<tr tal:repeat="row results">
    <td tal:content="python:row['name']">the name</td>
    <td tal:content="python:row['value']">1</td>
</tr>

The python: is also superfluous in Chameleon. Then, you can also use attribute access instead of dict access in templates:

<tr tal:repeat="row results">
    <td tal:content="row.name">the name</td>
    <td tal:content="row.value">1</td>
</tr>

Lastly, you can use the ${} substitution syntax instead of tal:content. That'll give you a much more compact spelling:

<tr tal:repeat="row results">
    <td>${row.name}</td>
    <td>${row.value}</td>
</tr>

And maybe, while doing this, you'll solve your actual problem on the way. ;-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!