Question

Anyone know how I could show entry/entries as appropriate, in the following fragment of Genshi syntax?

  <span py:if="c.page.item_count">
    ${c.page.item_count} entries.
  </span>

Thanks!

Was it helpful?

Solution

Not pretty, but should work

<span py:if="c.page.item_count">
  ${c.page.item_count} ${['entries','entry'][c.page.item_count==1]}.
</span>

or

<span py:if="c.page.item_count">
  ${c.page.item_count} ${'entry' if c.page.item_count==1 else 'entries'}.
</span>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top