I wondered if anyone could help me with turning the following in ERB
into HAML. I''m VERY new with HAML:
----
<div class="block-element span-7 colborder">
<span class="rightside blue-hue no_decor"><%= link_to
"New Order",
new_order_path, :remote => true %></span>
<h3>Today''s Activity</h3>
<hr>
<div id="order">
<ul>
<% @orders.each do |order| %>
<li><span class="pull-2 box"><%=
"#{leading_zeros order.id}"
%></span> <%= link_to "#{order.name}", order, :remote
=> true %></li>
<span class="rightside"><%= link_to
''Delete'', order, :confirm => ''Are
you sure?'', :method => :delete %></span>
<li class="time_space"><span class="quiet small
time"><%distance_of_time_in_words_to_now(order.created_at,
:include_seconds =>
true) %> ago</span></li>
<% end %>
</ul>
</div>
<div class="page_nav">
Pagination goes here
</div>
<br />
</div>
----
I have tried it a few different ways to convert this to HAML, but I''m
messing it up on this secion (which is the meat of the document):
----
<ul>
<% @orders.each do |order| %>
<li><span class="pull-2 box"><%= "#{leading_zeros
order.id}" %></span>
<%= link_to "#{order.name}", order, :remote => true
%></li> <span
class="rightside"><%= link_to ''Delete'', order,
:confirm => ''Are you
sure?'', :method => :delete %></span>
<li class="time_space"><span class="quiet small
time"><%distance_of_time_in_words_to_now(order.created_at,
:include_seconds =>
true) %> ago</span></li>
<% end %>
</ul>
----
I have it in HAML as:
----
%ul= @orders.each do |order|
%li
%span.pull-2.box= "#{leading_zeros order.id}"
= link_to "#{order.name}", order, :remote => true
%span.rightside= link_to ''Delete'', order, :confirm =>
''Are you sure?'',
:method => :delete
%li.time_space
%span.quiet.small.time{distance_of_time_in_words_to_now(order.created_at,
:include_seconds =>
true)} ago
= end
----
I''m not sure how to correct this. Any help on formatting the ruby code
would be greatly appreciated. That''s where it seems to fail on me. I
have multiple spans on the same line in ERB. Should I do each span on
its own line?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt Royer wrote:> I wondered if anyone could help me with turning the following in ERB > into HAML.Do you mean ERb and Haml? :)> I''m VERY new with HAML:Run it through html2haml and see what you get. Note, however, that it will usually produce %span = content where you generally want %span= content Other than that, it''s great to help you get started. [...]> > I have tried it a few different ways to convert this to HAML, but I''m > messing it up on this secion (which is the meat of the document): > > ---- > <ul> > <% @orders.each do |order| %> > > <li><span class="pull-2 box"><%= "#{leading_zeros order.id}" %></span> > <%= link_to "#{order.name}", order, :remote => true %></li> <span > class="rightside"><%= link_to ''Delete'', order, :confirm => ''Are you > sure?'', :method => :delete %></span> > > <li class="time_space"><span class="quiet small time"><%> distance_of_time_in_words_to_now(order.created_at, :include_seconds => > true) %> ago</span></li> > > <% end %> > </ul> > ---- > > I have it in HAML as: > > ---- > > %ul= @orders.each do |order| > %li > %span.pull-2.box= "#{leading_zeros order.id}" > = link_to "#{order.name}", order, :remote => true > %span.rightside= link_to ''Delete'', order, :confirm => ''Are you sure?'', > :method => :delete > %li.time_space > %span.quiet.small.time> {distance_of_time_in_words_to_now(order.created_at, :include_seconds => > true)} ago > = endThat''s not even close to right. You need to learn about the use of - instead of = in Haml. Reread the language reference.> > ---- > > I''m not sure how to correct this. Any help on formatting the ruby code > would be greatly appreciated. That''s where it seems to fail on me. I > have multiple spans on the same line in ERB. Should I do each span on > its own line?Yes. Haml has no notion of multiple elements on one line. If white space is an issue, you can use Haml''s < and > modifiers -- or include bits of HTML or ERb if you really need to (it is *occasionally* necessary to do so). Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote:> Run it through html2haml and see what you get. Note, however, that it > will usually produce > > %span > = content > > where you generally want > > %span= content > > Other than that, it''s great to help you get started.PERFECT! Thanks Marnen! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.