diff --git a/lib/builder/xmlbase.rb b/lib/builder/xmlbase.rb index 8f03a82..2fac283 100644 --- a/lib/builder/xmlbase.rb +++ b/lib/builder/xmlbase.rb @@ -41,6 +41,7 @@ def explicit_nil_handling? def tag!(sym, *args, &block) text = nil attrs = nil + escape_text = true sym = "#{sym}:#{args.shift}" if args.first.kind_of?(::Symbol) sym = sym.to_sym unless sym.class == ::Symbol args.each do |arg| @@ -51,6 +52,8 @@ def tag!(sym, *args, &block) when nil attrs ||= {} attrs.merge!({:nil => true}) if explicit_nil_handling? + when true, false + escape_text = arg else text ||= '' text << arg.to_s @@ -78,7 +81,11 @@ def tag!(sym, *args, &block) else _indent _start_tag(sym, attrs) - text! text + if escape_text + text! text + else + self << text + end _end_tag(sym) _newline end diff --git a/test/test_markupbuilder.rb b/test/test_markupbuilder.rb index 562b12a..59eabc8 100644 --- a/test/test_markupbuilder.rb +++ b/test/test_markupbuilder.rb @@ -194,6 +194,11 @@ def test_non_escaping assert_equal %{