Opened 12 years ago
Closed 11 years ago
#541 closed defect (fixed)
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.
Change History (3)
comment:1 Changed 12 years ago by hodgestar
- Owner changed from cmlenz to hodgestar
comment:2 Changed 12 years ago by hoff.st@…
I've been using Trac dependencies for most of my test environments, so this should be equal to genshi-0.6 release as I guess.
Thanks for the hint on fixes in 0.6.x. I'll have to setup another test environment with focus on latest Genshi code. Hope to report my findings soon.
comment:3 Changed 11 years ago by hodgestar
- Resolution set to fixed
- Status changed from new to closed
Since 0.6.1 has been released with the fixes I mentioned I'm closing this for now. Please re-open in necessary.
Are you using the latest 0.6.x version from svn or the 0.6.0 release? If you're not using the latest 0.6.x could you try that? I think some related bugs were fixed in svn awhile ago.