This is the way Haml originally functioned... but I'm sure there
was some reason why we didn't do the tag suppression.

Precompiling issues, I think?

-hampton.

On Fri, Oct 2, 2009 at 2:46 PM, Alexander Wallace
<[email protected]>wrote:

> I think that would be a very valuable configuration - similar to how we can
> set certain tags to be self-closing (br, hr, etc) it would also be a great
> feature to be able to set certain tags to simply not output if they are
> empty (li in this case).
> Alex
>
>
> On Fri, Oct 2, 2009 at 9:19 AM, Widi Harsojo <[email protected]> wrote:
>
>>
>> in my own library "w2tags", I create a wrap(I call it a hot tag
>> "-user_path"), and it will expand on erb
>>
>> inside file 'include.w2erb'
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> !H! _user_path
>>  -if permitted_to? :manage, :users
>>   %li= link_to "Users", users_path
>>
>> source 'index.w2erb'
>> ~~~~~~~~~~~~~~~~~~~~
>> !inc!include.w2erb
>>
>> -user_path
>>
>> How about principle "DRY-UP the view"
>>
>> inside file 'include.w2erb'
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> !H!_each2
>>  - $0.each_with_index do |$0|
>>  -end
>>
>> !H! _td
>>  -each2 @rec;r,i
>>   %tr.pop-up-show{pop="#grid-pop-edit" class="d r<%=i+1%>"}
>>     ~^%td $0
>>     ^.c1.c;.c2;.c3;.c4;.c5;.c6;.c7;.c8;.c9;.c10= $*
>>
>> source 'index.w2erb'
>> ~~~~~~~~~~~~~~~~~~~~
>> !inc!include.w2erb
>>
>> %table
>>  -td i+1 ; r[:cus_code] ; r[:cus_name] ; r[:cus_type]
>> #page.h{page=<%= @page%>}
>>
>> OR you can code like this
>>
>> %table
>>  -td i+1;\
>>  r[:cus_code];\
>>  r[:cus_name];\
>>  r[:cus_type]
>> #page.h{page=<%= @page%>}
>>
>> OR...
>>
>> %table
>>  - @rec.each_with_index do |$0|
>>   %tr.pop-up-show{pop="#grid-pop-edit" class="d r<%=i+1%>"}
>>     %td.c1.c= i+1
>>     %td.c2= r[:cus_code]
>>     %td.c3= r[:cus_name]
>>     %td.c4= r[:cus_type]
>>  - end
>> #page.h{page=<%= @page%>}
>>
>> if you refresh your browser it will parse and generate 'index.erb'
>>
>> result 'index.erb'
>> ~~~~~~~~~~~~~~~~~~
>> <table>
>>  <% @rec.each_index do |r,i| %>
>>   <tr class="pop-up-show" pop="#grid-pop-edit" class="d r<%=i+1%>">
>>     <td class="c1 c"><%= i+1 %></td>
>>     <td class="c2"><%= r[:cus_code] %></td>
>>     <td class="c3"><%= r[:cus_name] %></td>
>>     <td class="c4"><%= r[:cus_type] %></td>
>>   </tr>
>>  <% end %>
>> </table>
>> <div id="page" class="h" page=<%= @page%>>
>>
>>
>> On Fri, Oct 2, 2009 at 4:02 AM, Dr Nic Williams <[email protected]>
>> wrote:
>> > Sounds valid, and interesting to me.
>> > On Fri, Oct 2, 2009 at 7:58 PM, [email protected] <[email protected]>
>> wrote:
>> >>
>> >> Hi!
>> >>
>> >> I have been using haml almost years now :-)
>> >>
>> >> Now I have got one small idea, just need your opinion if this does not
>> >> go against some fundamental haml way. If not then I would dig deeper
>> >> and write some patch or smth.
>> >>
>> >> Currently:
>> >>
>> >> %li= nil
>> >>
>> >> It will return empty element <li></li> however I would prefer if it
>> >> does not return anything at all. Why?
>> >>
>> >> Cos I'm using declarative authorization gem and often write code like:
>> >>
>> >> %li= link_to "Users", users_path if permitted_to? :manage, :users
>> >>
>> >> However sometimes I have css style for li elements and empty element
>> >> got style as well. So at the moment I have to write code what is not
>> >> so nice and one liner any more:
>> >>
>> >> - if permitted_to? :manage, :users
>> >>  %li= link_to "Users", users_path
>> >>
>> >> I have quite many permitted_to? methods in my views, so that's why I
>> >> thought I need some global option for Nil not to return any output.
>> >>
>> >> What do you think?
>> >>
>> >> Cheers,
>> >> Priit
>> >>
>> >
>> >
>> >
>> > --
>> > Dr Nic Williams
>> > iPhone and Rails consultants - http://mocra.com
>> > Fun with iPhone/Ruby/Rails/Javascript - http://drnicwilliams.com
>> > * Surf Report for iPhone - http://mocra.com/projects/surfreport/ *
>> >
>>
>>
>> --
>> /wh
>>
>> e=mc2inhologram
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to