Forum: Ruby on Rails Using spacer img in menu

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jolé (Guest)
on 2007-07-03 01:08
(Received via mailing list)

This is what I want....

blog | photos | about

This is what my code gives me.....

blog | photos | about |

The last "|" is to much....

  <% for page in @menu_pages %>
  <% end %>

Is there any way I can get some sort of indication whether the array
@menu_pages has a next element?

-- Jelle
Raymond S. (Guest)
on 2007-07-03 01:25
(Received via mailing list)
On Mon, 2007-07-02 at 14:07 -0700, Jolé wrote:
> Hi!
> This is what I want....
> blog | photos | about

I use this:

        <%= render(:partial => 'navbar_item',
                   :collection => @navbar_items,
                   :spacer_template => 'navbar_spacer') %>

With obviously navbar_item displaying an item and the navbar_spacer the

Gr. Raymond
Raymond S.
Rob B. (Guest)
on 2007-07-03 01:56
(Received via mailing list)
On Jul 2, 2007, at 5:07 PM, Jolé wrote:
> The last "|" is to much....
> -- Jelle

<%= { |page|
       content_tag(:li, page.to_s)
     }.join(content_tag(:li, '|')) %>

Which should probably be extracted to a helper so you can call:

<%= menu_items_for(@menu_pages, '|') %>

And there will probably be someone who says "you should use do-end
for a multi-line block", but I'm believing (and trying to follow) Jim
Weirich's style of using {} when the value of the block is used and
do-end otherwise (or when precedence dictates).


Rob B.
This topic is locked and can not be replied to.