Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed the ordering of attributes in the xml-decleration of Builder #540

… [woeye]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@505 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 136962322b8da0d6c09b4962194216cc4d248130 1 parent efa81da
@dhh dhh authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed the ordering of attributes in the xml-decleration of Builder #540 [woeye]
+
* Added @request.raw_post as a convenience access to @request.env['RAW_POST_DATA'] #534 [Tobias Luetke]
* Added support for automatic id-based indexing for lists of items #532 [dblack]. Example:
View
21 actionpack/lib/action_view/vendor/builder/xmlmarkup.rb
@@ -221,7 +221,7 @@ def declare!(inst, *args, &block)
# For example:
#
# xml.instruct!
- # #=> <?xml encoding="UTF-8" version="1.0"?>
+ # #=> <?xml version="1.0" encoding="UTF-8"?>
# xml.instruct! :aaa, :bbb=>"ccc"
# #=> <?aaa bbb="ccc"?>
#
@@ -231,7 +231,12 @@ def instruct!(directive_tag=:xml, attrs={})
a = { :version=>"1.0", :encoding=>"UTF-8" }
attrs = a.merge attrs
end
- _special("<?#{directive_tag}", "?>", nil, attrs)
+ _special(
+ "<?#{directive_tag}",
+ "?>",
+ nil,
+ attrs,
+ [:version, :encoding, :standalone])
end
private
@@ -245,11 +250,11 @@ def _text(text)
end
# Insert special instruction.
- def _special(open, close, data=nil, attrs=nil)
+ def _special(open, close, data=nil, attrs=nil, order=[])
_indent
@target << open
@target << data if data
- _insert_attributes(attrs) if attrs
+ _insert_attributes(attrs, order) if attrs
@target << close
_newline
end
@@ -269,10 +274,14 @@ def _end_tag(sym)
end
# Insert the attributes (given in the hash).
- def _insert_attributes(attrs)
+ def _insert_attributes(attrs, order=[])
return if attrs.nil?
+ order.each do |k|
+ v = attrs[k]
+ @target << %{ #{k}="#{v}"} if v
+ end
attrs.each do |k, v|
- @target << %{ #{k}="#{v}"}
+ @target << %{ #{k}="#{v}"} unless order.member?(k)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.