aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 12:47:11 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 12:47:11 +0000
commit136962322b8da0d6c09b4962194216cc4d248130 (patch)
tree51068b221da882b654546421543623c25f5a6985 /actionpack/lib/action_view
parentefa81dad5158eb61243d00811e4664248dd2c167 (diff)
downloadrails-136962322b8da0d6c09b4962194216cc4d248130.tar.gz
rails-136962322b8da0d6c09b4962194216cc4d248130.tar.bz2
rails-136962322b8da0d6c09b4962194216cc4d248130.zip
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
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/vendor/builder/xmlmarkup.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/vendor/builder/xmlmarkup.rb b/actionpack/lib/action_view/vendor/builder/xmlmarkup.rb
index 716ff52535..4f82704c20 100644
--- a/actionpack/lib/action_view/vendor/builder/xmlmarkup.rb
+++ b/actionpack/lib/action_view/vendor/builder/xmlmarkup.rb
@@ -221,7 +221,7 @@ module Builder
# 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 @@ module Builder
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 @@ module Builder
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 @@ module Builder
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