Notice that in the ERB examples for link_to_unless don't actually include
any raw HTML text within the block; that is, the entire block is within the
<%= ... %>. You need to do the same with Haml if you want to use the helper.
That means that you can't use = or any of the HTML-generating Haml code; you
have to use
- "<strong class='current'>#{h name}</strong>"
instead.
On Mon, Nov 16, 2009 at 7:54 AM, Tobias <[email protected]>wrote:
>
> Hi!
>
> I have a link to the users profile in my meta navigation and I am
> looking for an easy, automatic way to tell the user, that the is
> currently on the page that the link describes.
>
> This is good but not good enough, since I cannot assign an "active"
> class in case the page is the current page.
> = link_to_unless_current "your profile", user_url(current_user)
>
> According to the documentation (http://github.com/rails/rails/blob/
> 9e29c084eb0551eb18b666c8df53b9985af8aa16/actionpack/lib/action_view/
> helpers/url_helper.rb#L354<http://github.com/rails/rails/blob/%0A9e29c084eb0551eb18b666c8df53b9985af8aa16/actionpack/lib/action_view/%0Ahelpers/url_helper.rb#L354>)
> there is a solution for that:
> = link_to_unless_current "Dein Profil", user_url(current_user) do |
> name|
> %strong.current= name
>
> This works fine with one problem: It generates an unwanted "0" after
> the tag.
>
> Output if url is current:
> <strong class="current"> Dein Profil </strong>
> 0
>
> Where does this "0" come from and how do I get rid of it?
>
> Thanks a lot!
> Tobias
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to [email protected].
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=.