At 7:24 AM -0700 10/22/11, Romain Maz BILLOIR wrote: >Hi, i'm new with haml and i figured out my first problem: > >Why this: >%image#grass{:height => "29.32", :width => "38.64", "xlink:href" => >image_path('grass.svg')} >render properly: ><image height='29.32' id='grass' width='38.64' xlink:href='/assets/ >grass.svg'></image> > >But when added the "/" self-closing character: >%image#grass{:height => "29.32", :width => "38.64", "xlink:href" => >image_path('grass.svg')}/ >render badly: ><image height='29.32' id='grass' width='38.64' xlink:href='/assets/ >grass.svg'>
Romain, You might be interested in this work I did that will automatically force haml to switch to :xhtml format when serving a contentwith a text/xml' mime type. It could easily be adapted to do this if serving any content that should be well-formed xml. This pull request has not been merged into haml yet however ... At 1:25 AM -0400 9/9/11, Stephen Bannasch wrote: >Here's a new pull request: https://github.com/nex3/haml/pull/427 that fixes >the problem I was having with invalid XML being generated in a Rails 3 app. > >If the mime_type of the ActionView::Template being rendered is `text/xml` >then a format of `:xhtml` will be used even if the global output format >is set to `:html4` or `:html5`. > >I have a Rails app I am porting from 2.3.12 to 3.0.10 and we use Haml >templates for rendering xml. I would prefer for the html rendering >to use the Rails 3 default of :html5. > >The problem occurred because some of the XML elements being rendered >were being closed with just a '>' char. That of course made the XML >invalid. > >If options[:mime_type] is defined and the value == 'text/xml' >then an instanced Haml::Engine will always use :xhtml > >I created unit tests for this change. > >At one level up in the Haml::Plugin module if the >mime_type of the ActionView::Template template >being rendered is 'text/xml' then add the a :mime_type >key to the options hash so Haml::Engine will force a >format of xhtml. -- You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to haml@googlegroups.com. To unsubscribe from this group, send email to haml+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/haml?hl=en.