What you are looking for is tal:condition
, possibly combined with the not:
and exists:
prefixes:
<span tal:replace="here/getFieldA" />
<span tal:condition="not:exists:here/getFieldA" tal:replace="here/getFieldB" />
Alternatively, you can use the |
operator, which acts like an if operator, testing existence of the first element. If it doesn't exist, it'll use the next expression, and so on:
<span tal:replace="here/getFieldA | here/getFieldB" />
The tal:omit-tag
attribute means something very different. If it's expression evaluates to True
, then the tag, and only the tag itself, is omitted from the output. This is best illustrated with an example:
<span tal:omit-tag="">
<i>This part will be retained</i>
</span>
Rendering that piece of pagetemplate results in:
<i>This part will be retained</i>
The surrounding <span>
tag was omitted, but the contents were preserved.