alex wrote:
Is there any way to beatify the html that is emitted?
Get Tidy, and run this assertion from your functional tests:
def assert_tidy(messy = @response.body, verbosity = :noisy)
scratch_html = RAILS_ROOT + ‘/…/scratch.html’ # TODO tune me!
File.open(scratch_html, ‘w’){|f| f.write(messy) }
gripes = tidy -eq #{scratch_html} 2>&1
gripes.split("\n")
exclude, inclued = gripes.partition do |g|
g =~ / - Info: / or
g =~ /Warning: missing <!DOCTYPE> declaration/ or
g =~ /proprietary attribute/ or
g =~ /lacks “(summary|alt)” attribute/
end
puts inclued if verbosity == :noisy
# inclued.map{|i| puts Regexp.escape(i) }
assert_xml tidy -wrap 1001 -asxhtml #{scratch_html} 2>/dev/null
# CONSIDER that should report serious HTML deformities
end
You can take out the assert_xml if you don’t have yar_wiki (whence that
comes).
The system will push a scratch.html file into your parent folder, and if
the
errors Tidy reports are not utterly trivial, it will barf them out when
your
tests run.
When upgrading old websites to Rails I always run things through
Tidy -i -asxhtml, before inserting the <%%> tags. The difference in
development speed is astounding, when I don’t need to count the freakin’
tags just to nest everything correctly.
My Short Cut with O’Reilly has lots more tips on keeping the HTML clean.
http://www.oreilly.com/catalog/9780596510657
–
Phlip
http://flea.sourceforge.net/PiglegToo_1.html