Converting a complex html.erb anchor to haml
I have the following code in a partial that I am trying to convert to HAML. Everything is easy until the anchor.
<% @user ||= current_user %>
<div class="stats">
<table summary="User stats">
<tr>
<td>
<a href="<%= following_user_path(@user) %>">
<span id="following" class="stat">
<%= @user.following.count %> following
</span>
</a>
I got it close with:
- @user ||= current_user
.stats
%table{ :summary => "User stats" }
开发者_开发百科 %tr
%td
%a
= following_user_path(@user)
%span.stat#following
= @user.following.count
following
but the anchor does not quite come out right. I believe that I should be able to do this with a link_to but I am unclear on how to mix the embedded SPAN tag within the arguments for link_to. How should this be done? Thank you for any help.
TomYou could use the link_to
helper:
= link_to following_user_path(@user) do
%span#following.stat
== #{@user.following.count} following
I think you can use:
%a{ :href => following_user_path(@user) }
%span.stat#following
= @user.following.count
following
精彩评论