Cómo crear CSS zebra-stripe con TAL?
¿Cómo puedo usar las plantillas de página Chameleon o Zope para crear fácilmente CSS zebra striping? Quiero agregar odd
y even
clases a cada fila de una tabla, pero usar una condición con repeat/name/odd
o repeat/name/even
parece bastante detallado incluso con una expresión condicional:
<table>
<tr tal:repeat="row rows"
tal:attributes="class python:repeat['row'].odd and 'odd' or 'even'">
<td tal:repeat="col row" tal:content="col">column text text</td>
</tr>
</table>
Esto se vuelve especialmente tedioso si tiene varias clases para calcular.
40
Author: Martijn Pieters, 2013-12-19
1 answers
La implementación de Plantillas de página Zope para la variable repeat
tiene un parámetro extra sub-documentado, parity
, que le da la cadena 'odd'
o 'even'
, alternando entre iteraciones:
<table>
<tr tal:repeat="row rows"
tal:attributes="class repeat/row/parity">
<td tal:repeat="col row" tal:content="col">column text text</td>
</tr>
</table>
Esto también es mucho más fácil de interpolar en una expresión de cadena:
tal:attributes="class string:striped ${row/class} ${repeat/row/parity}"
Esto también funciona en Camaleón.
26
Author: Martijn Pieters,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-19 18:19:16
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-19 18:19:16