Arg, I've successully posted tags using gmail before, I don't know why
it failed this time.   Trying again.

<!-- Repeats the body of the tag inside a `<ul>` list with one item
for each object in the collection (`this`). If no body is given,
renders a `<card>` inside the `<li>`.

Automatically adds 'even' and 'odd' CSS classes.

`empty-collection-message` is called from this tag.   To suppress you
can use the `without-empty-message` pseudo-attribute:

    <collection without-empty-message/>

If your collection is an ActiveRecord result set (and in Hobo it most
likely is), the best way to customize the empty message is via
translations.   Example: for product models, the key to customize
would be `products.collection.empty_message`.

If your collection is a generic array, empty-collection-message
doesn't work.   `<collection>` also sets the last_if flag, so you can
use the `<else>` tag to display a message:

    <collection with="&[]"/>
    <else>No items.</else>

### Attributes

- list-tag:  set to 'ol' if you prefer that over 'ul'.
 -->
<def tag="collection" attrs="list-tag">
  <% list_tag ||= 'ul' %>
  <call-tag tag="&list_tag" class="collection
#{collection_name :dasherize => true}" merge-attrs unless="empty?">
    <li param="item" class="#{scope.even_odd} #{model_id_class}"
repeat="&select_viewable">
      <do param="default"><card param/></do>
    </li>
  </call-tag>
  <empty-collection-message param="empty-message"/>
  <if/><%# set last-if so <else/> works %>
</def>

<!-- Renders a message such as "No products to display". If the
collection (`this`) is empty, `style="display:none"` is added. This
means the message is still present and can be revealed with JavaScript
if all items in the collection are removed via ajax remove buttons.
  -->
<def tag="empty-collection-message">
  <unless test="&this._?.member_class.nil?">
    <div class="empty-collection-message" style="#{'display:none' if !
this.empty?}" param="default">
      <ht
key="#{this.member_class.name.underscore}.collection.empty_message">
        No <collection-name/> to display
      </ht>
    </div>
  </unless>
</def>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to