1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

The attributes list is now sorted.

git-svn-id: svn://hamptoncatlin.com/haml/branches/edge@82 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-10-20 02:38:53 +00:00
parent 89a10b9dfe
commit 2de8d1c9b7
3 changed files with 10 additions and 21 deletions

View file

@ -120,7 +120,13 @@ module Haml
# Takes a hash and builds a list of XHTML attributes from it, returning
# the result.
def build_attributes(attributes = {})
result = attributes.collect do |a,v|
attributes.each do |key, value|
unless key.is_a? String
attributes.delete key
attributes[key.to_s] = value
end
end
result = attributes.sort.collect do |a,v|
unless v.nil?
first_quote_type = v.to_s.scan(/['"]/).first
quote_type = (first_quote_type == "'") ? '"' : "'"

View file

@ -2,7 +2,7 @@
<html xml-lang='en-US'>
<head>
<title>Hampton Catlin Is Totally Awesome</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
</head>
<body>
<!-- You're In my house now! -->

View file

@ -9,17 +9,6 @@ require File.dirname(__FILE__) + '/../lib/haml/template'
require File.dirname(__FILE__) + '/mocks/article'
class TemplateTest < Test::Unit::TestCase
# These are specific lines of templates that, for one reason or
# another, might not be exactly equivalent to the pre-rendered
# version.
EXCEPTIONS = {
'standard' => [
# Line 4 has many attributes; because attributes aren't sorted,
# this can vary unpredictably.
4
]
}
def setup
ActionView::Base.register_template_handler("haml", Haml::Template)
@base = ActionView::Base.new(File.dirname(__FILE__) + "/../test/templates/")
@ -38,14 +27,8 @@ class TemplateTest < Test::Unit::TestCase
def assert_renders_correctly(name)
load_result(name).split("\n").zip(@base.render(name).split("\n")).each_with_index do |pair, line|
if (EXCEPTIONS['name'].nil? || EXCEPTIONS['name'].include?(line))
if pair.first != pair.last
puts "\nWarning: line #{line} of template \"#{name}\" may have rendered incorrectly."
end
else
message = "template: #{name}\nline: #{line}"
assert_equal(pair.first, pair.last, message)
end
message = "template: #{name}\nline: #{line}"
assert_equal(pair.first, pair.last, message)
end
end