OK, here's the new definition. Something very similar will end up in
Hobo 1.4, but here it is for those who want it early.
Besides the update discussed, it has been updated to work better with
non-ActiveRecord arrays.
Bryan
<!-- 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>
On Thu, Dec 22, 2011 at 7:28 AM, Ronny Hanssen <[email protected]> wrote:
> Ah. Yes, you are right. Didn't think about the fact that the collections can
> be multi-typed.
>
> I then suggest that the ul is turned into a ol, with the option to override
> it, using a "list-tag" parameter.
>
> Any objections to that idea?
>
>
> ~Ronny
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/T3ypw4DMVVsJ.
>
> 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.
--
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.