Ticket #541 (new defect)
i18n directive interferes with py:if expression
| Reported by: | hoff.st@… | Owned by: | hodgestar |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.7 |
| Component: | Template processing | Version: | 0.6 |
| Keywords: | i18n | Cc: |
Description
I want to exclude a 'span' HTML element, if value=0. This is the minimized template markup for this use case:
<label i18n:msg="timedelta">
Duration:
<input type="text" name="input"
value="$value" />
seconds
<span py:if="value">
(${fmt_value(value)})
</span>
</label>
I've added the i18n directive to get a msgid like
'Duration: [1:] seconds [2:](%(timedelta)s[3:]'
instead of split msgids 'Duration:', 'seconds', ...).
But with value=0 the py:if directive seems ineffective:
<label>Duration:
<input type="text" name="input" value="0" />
seconds
<span>
()
</span></label>
The 'span' element is included regardless of the value of 'value'.
Simply removing the i18n directive like
<label>
Duration:
<input type="text" name="input"
value="$value" />
seconds
<span py:if="value">
(${fmt_value(value)})
</span>
</label>
fixes this:
<label>Duration: <input type="text" name="input" value="0" /> seconds </label>
'span' disappears correctly, if value=0. If not for the braces I wouldn't have noticed this nor would I care.
Maybe there is a related issue in the Internationalization domain: When the py:if directive would strip the 'span' element successfully, the expression i18n:msg="timedelta" would become invalid. Not sure, if that would hurt on template rendering time.
