Discussion: Code Reduction
Afficher un message
Vieux 21/02/2008, 16h07   #3
Jigar Gosar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Code Reduction

Cool, thanks.

The "if v" can be removed, cause if the key exists than there is no
problem in rendering its value.

Thanks a lot, that was a really quick reply.

I just love ruby, cause so much can be expressed in so less.

Arlen Cuss wrote:
> Hey,
>
> If you call your CSS class for a `notice' flash NoticeMessage isntead of
> just Message, you can make it simple like this:
>
> <% flash.each do |k, v| %>
> <% if v %>
> <div class="MessageWrapper">
> <span class="<%= k.to_s.capitalize %>Message">
> <%= v %>
> </span>
> </div>
> <% end %>
> <% end %>
>
> Cheers,
> Arlen.


--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
 
Page generated in 0,04534 seconds with 9 queries