public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Don't auto-preserve when in ugly mode

In ugly mode there is no need to automatically preserve whitespace for
pre and textarea tags because all output will be left-indented anyway.
This means less work for ugly mode and ironically makes the output less
"ugly" because it doesn't insert the HTML entities for newlines.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
Signed-off-by: Nathan Weizenbaum <nex342@gmail.com>
wincent (author)
Tue May 27 12:16:24 -0700 2008
nex3 (committer)
Tue May 27 12:52:39 -0700 2008
commit  62137499b549fa521ce94701a82f02a6424c72a4
tree    e63d74d4ae3f7426a0c1163b8e9a3b5f837b7780
parent  d52a2a2250d8776ece71d8ad22064fbf16f9fc5c
...
545
546
547
 
548
549
550
...
545
546
547
548
549
550
551
0
@@ -545,6 +545,7 @@ END
0
 
0
       preserve_tag = options[:preserve].include?(tag_name)
0
       nuke_inner_whitespace ||= preserve_tag
0
+ preserve_tag &&= !options[:ugly]
0
 
0
       case action
0
       when '/'; self_closing = xhtml?
...
541
542
543
 
 
 
 
 
 
 
544
545
546
...
541
542
543
544
545
546
547
548
549
550
551
552
553
0
@@ -541,6 +541,13 @@ END
0
                  render("%p= 's' * 75", :ugly => true))
0
   end
0
 
0
+ def test_auto_preserve_unless_ugly
0
+ assert_equal("<pre>foo&#x000A;bar</pre>\n", render('%pre="foo\nbar"'))
0
+ assert_equal("<pre>foo\nbar</pre>\n", render("%pre\n foo\n bar"))
0
+ assert_equal("<pre>foo\nbar</pre>\n", render('%pre="foo\nbar"', :ugly => true))
0
+ assert_equal("<pre>foo\nbar</pre>\n", render("%pre\n foo\n bar", :ugly => true))
0
+ end
0
+
0
   def test_xhtml_output_option
0
     assert_equal "<p>\n <br />\n</p>\n", render("%p\n %br", :format => :xhtml)
0
     assert_equal "<a />\n", render("%a/", :format => :xhtml)

Comments

    No one has commented yet.