Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

Affinitic: Omit attribute in TAL

$
0
0

I always tough than it was impossible to completely omit a tag attribute using TAL. So when I wanted to automatically check or not a radio button, I duplicated it like this:

<input type="radio" tal:condition="mycondition" checked="checked" />
<input type="radio" tal:condition="not:mycondition" />

But we can omit a tag attribute by passing nothing to a tal:attributes, like this:

<input type="radio" tal:attributes="python:mycondition and 'checked' or nothing" />

It’s so cleaner!


Viewing all articles
Browse latest Browse all 3535

Trending Articles