Skip to content

Instantly share code, notes, and snippets.

@aron
Created May 14, 2012 10:55
Show Gist options
  • Save aron/2693287 to your computer and use it in GitHub Desktop.
Save aron/2693287 to your computer and use it in GitHub Desktop.
<!--!
Generate <li>s for facet items. The generated tags are not wrapped by any
other tag, ie - it's up to the caller to wrap them in something suitable.
name
The field name identifying the facet field, eg. "tags"
label_function
Renders the human-readable label for each facet value.
If defined, this should be a callable that accepts a `facet_item`.
eg. lambda facet_item: facet_item.display_name.upper()
By default it displays the facet item's display name, which should
usually be good enough
if_empty
A string, which if defined, and the list of possible facet items is empty,
is displayed in a <li> tag in lieu of an empty list.
count_label
A callable which accepts an integer, and returns a string. This controls
how a facet-item's count is displayed.
-->
<li>
<a href="${c.drill_down_url(name=item.name)}">
${label_function(item) if vars().has_key('label_function') else item.display_name}
${count_label(item['count']) if vars().has_key('count_label') else ('(%d)' % item['count'])}
</a>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment