[Zope3-dev] ? vs $
Barry A. Warsaw
barry@zope.com
Fri, 14 Jun 2002 14:31:31 -0400
>>>>> "JPS" == Jeffrey P Shell <jeffrey@cuemedia.com> writes:
JPS> I agree. But I think it could be more useful (potentially)
JPS> to use the String expression syntax, and to run a path
JPS> through the String expression engine before doing traversal.
I agree. I'd like to see Steve's example written like:
| <tr tal:repeat="jobid context/getApprovedIds">
| <td>
| <a href="jobid" tal:attributes="href jobid">
| <span tal:replace="context/?jobid/summary">A job summary</span></A>
| </td>
| </tr>
[or]
| <span tal:replace="python:path('context/%s/summary' % jobid)">
| A job summary</span></A>
[better]
<tr tal:repeat="jobid context/getApprovedIds">
<td>
<a href="jobid" tal:attributes="href jobid">
<span tal:replace="context/$jobid/summary">A job summary</span></a>
</td>
</tr>
If you're worried about colliding with identifiers that start with $,
write
<span tal:replace="context/${jobid}/summary">...
Probably a low likelihood of collisions (and if so, use $$ to
disambiguate). I think it's more important to make similar operations
look similar so it's clear at first glance what the intention is.
-Barry