1

I am actually generating some xml from haml template, using Padrino Framework. There are some tags that are self closing. For that I did add following statement in subapp/app.rb as padrino is based on sinatra

set :haml, :autoclose => %w[meta img link br hr input area param col base else var assign script log submit exit reprompt goto]

But the Result is same for 1. else tag I get

<else> </else>

but expected is

<else />

Similar to br tag.

rene
  • 41,474
  • 78
  • 114
  • 152
Jai Madhav
  • 603
  • 8
  • 17

2 Answers2

1

Try with in config/boot.rb

require 'haml/template/options'
Haml::Template.options[:autoclose] = %w[meta img link br hr input area param col base else var assign script log submit exit reprompt goto]
DAddYE
  • 1,719
  • 11
  • 16
0

It has to be like this, if you're outside of Rails:

require 'haml/template/options'
Haml::Options.defaults[:format] = :xhtml
yegor256
  • 102,010
  • 123
  • 446
  • 597