<count>
A convenience tag used to output a count and a correctly pluralised label. Works with any kind of collection such as an ActiveRecord association or an array.
Usage
<count:comments/> -> <span class="count">1 Comment</span>
<count:viewings/> -> <span class="count">3 Viewings</span>
The label can be customised using the label attribute, e.g.
<count:comments label="blog post comment"/> -> <span class="count">12 blog post comments</span>
Additional Notes
-
Use the
prefixattribute to insert words before the count. If the prefix is “are” or “is” then it will be pluralised if needed:There <count:comments prefix="are"/> -> There <span class="count">is 1 Comment</span> There <count:viewings prefix="are"/> -> There <span class="count">are 3 Viewings</span> -
Use the
lowercaseattribute to force the generated label to be lowercase:<count:comments lowercase/> -> <span class="count">1 comment</span> -
Use the
if-anyattribute to output nothing if the count is zero. This can be followed by an<else>tag to handle the empty case:<count:comments if-any/><else>There are no comments</else>