Hi Gabriel,
On Dec 23, 2009, at 1:53 PM, G. Sobrinho wrote:
> Hi,
>
> I'm using HAML on my projects and I having a trouble with
> link_to_unless_current.
>
> Reading the Rails documentation you can use:
>
> <%=
> link_to_unless_current("Comment", { :controller => 'comments',
> :action => 'new}) do
> link_to("Go back", { :controller => 'posts', :action => 'index' })
> end
> %>
>
> I want a similar behavior, like this:
>
> = link_to_unless_current('Contact', contact_index_path) { link_to
> 'Contact', contact_index_path, :class => 'active' }
>
> Not that this works but the line is too big. To make the line more
> readable i'm trying to use:
>
> = link_to_unless_current('Contact', contact_index_path) do
> = link_to 'Contact', contact_index_path, :class => 'active'
Try:
= link_to_unless_current('Contact', contact_index_path) do
- link_to 'Contact', contact_index_path, :class => 'active'
Note the '-' instead of '=' in the second line. It means that that
line should be executed, but the result shouldn't be appended to the
page. This is equivalent to the ERB you included above and the first
(single line) haml version.
Rhett
>
> But this create a unexpected "7" on the source. If i'm outside contact
> page this works fine. But if i'm on contact page (which will use the
> block) the rendered HTML render this:
>
> <ul>
> <li><a href="/">Home</a></li>
> <li><a href="/pages/about-us">About US</a></li>
> <li>
> <a href="/contact" class="active">Contact</a>
> 7
> </li>
>
> </ul>
>
>
> It's a HAML related issue or I need to do it in another way?
>
> --
> Cordialmente,
>
> Gabriel Sobrinho
> Diretor de desenvolvimento
>
> Hite - Comunicação Digital e Mídia Interativa
> http://www.hite.com.br/
>
> +55 31 8775 8378
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "Haml" 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/haml?hl=en
> .
>
>
--
You received this message because you are subscribed to the Google Groups
"Haml" 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/haml?hl=en.