Subtle difference in how HAML handles render method with block in Rails templates -
Subtle difference in how HAML handles render method with block in Rails templates -
i stumbled across looks inconsistency in how haml handles render
method in rails.
example 1 in erb:
# template.html.erb index template. <%= render :layout => 'form4', :partial => 'stuff2' %> # _layout.html.erb <%= form_tag %> <div class="something"> <%= yield %> </div> <% end %> # _partial.html.erb <b>meh</b> <%= text_field_tag 'name' %>
example 1 in haml:
# template.html.haml index template. =render :layout => 'form2', :partial => 'stuff1' # _layout.html.haml =form_tag .something =yield # _partial.html.haml %b meh =text_field_tag 'name'
as expected, both result in same rendering (abbreviated below):
this index template. <form> <div class="something"> <b>meh</b> <input id="name" name="name" type="text" /> </div> </form>
now, here's weirdness kicks in. when adjust render
statement utilize block syntax below:
in erb:
# template.html.erb index template. <%= render :layout => 'form3' %> <b>meh</b> <%= text_field_tag 'name' %> <% end %> # _layout.html.erb <%= form_tag %> <div class="something"> <%= yield %> </div> <% end %>
in haml:
# template.html.haml index template. =render :layout => 'form1' %b meh =text_field_tag 'name' # _layout.html.haml =form_tag .something =yield
i same above rendering in erb version, haml code outputs:
this index template. <b>meh</b> <input id="name" name="name" type="text" /> <form> <div class='something'></div> </form>
it if haml somehow isn't respecting block passed it. according haml's docs, back upwards blocks autoclose based on indentation, don't suspect issue. also, in docs, saw definition render
method of own. possible isn't implemented accompany same interface rails's (erb's?) render
method?
on note, if inconsistency in methods interface, justify opening issue on haml?
just added illustration app showing behavior @ https://github.com/iamvery/haml-weirdness
it's worth noting noticed alter when upgraded rails app 3.0.9 , haml 3.1.2. leaving haml @ 3.0.24 resulted in cannot modify safebuffer in place
error in rails 3.0.9...
yes having same issue. described @ https://github.com/nex3/haml/issues/412 there issue_412 branch @ nex3's github business relationship not complete. take shot @ fixing haml, decided go rails 3.0.7.
ruby-on-rails haml
Comments
Post a Comment