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

Revert "Don't render unsightly XHTML newline escapes."

This reverts commit 0d4010cbaa.

This whole idea falls down when the toplevel template isn't necessarily active
when nested templates are being rendered.
Unfortunately, this is exactly the case for Rails and Merb,
which render the page template and then give the content to the layout.

This revert preserves some of the documentation added in the reverted commit.
This commit is contained in:
Nathan Weizenbaum 2008-04-24 12:59:03 -07:00
parent 0d4010cbaa
commit 97de8a5459
8 changed files with 32 additions and 117 deletions

View file

@ -850,10 +850,6 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
#
# Blocks of literal text can be preserved using the :preserve filter (see above).
#
# After the top-level Haml template has been processed,
# all newline escapes are converted back into literal newlines
# to make the source code more readable.
#
# === Helpers
#
# Haml offers a bunch of helpers that are useful

View file

@ -87,13 +87,6 @@ module Haml
@real_tabs = 0
end
# Returns the compiled string.
# This is distinct from #buffer in that some post-processing is done.
def result
return buffer unless @options[:ugly] || toplevel?
buffer.gsub('&#x000A;', "\n")
end
# Renders +text+ with the proper tabulation. This also deals with
# making a possible one-line tag one line or not.
def push_text(text, tab_change = 0)

View file

@ -171,7 +171,7 @@ END
@haml_buffer = buffer.upper
end
buffer.result
buffer.buffer
end
alias_method :to_html, :render

View file

@ -102,7 +102,7 @@ _erbout = _hamlout.buffer
END
postamble = <<END.gsub("\n", ";")
@haml_buffer = @haml_buffer.upper
_hamlout.result
_erbout
END
preamble + locals_code(local_names) + @precompiled + postamble
end

View file

@ -121,10 +121,10 @@ END
end
def test_textareas
assert_equal("<textarea>Foo\n bar\n baz</textarea>\n",
assert_equal("<textarea>Foo&#x000A; bar&#x000A; baz</textarea>\n",
render('%textarea= "Foo\n bar\n baz"'))
assert_equal("<pre>Foo\n bar\n baz</pre>\n",
assert_equal("<pre>Foo&#x000A; bar&#x000A; baz</pre>\n",
render('%pre= "Foo\n bar\n baz"'))
assert_equal("<textarea>#{'a' * 100}</textarea>\n",

View file

@ -82,13 +82,13 @@ class HelperTest < Test::Unit::TestCase
end
def test_text_area
assert_equal(%(<textarea id="body" name="body">Foo\nBar\n Baz\n Boom</textarea>\n),
assert_equal(%(<textarea id="body" name="body">Foo&#x000A;Bar&#x000A; Baz&#x000A; Boom</textarea>\n),
render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view))
assert_equal(%(<textarea cols="40" id="post_body" name="post[body]" rows="20">Foo bar\nbaz</textarea>\n),
assert_equal(%(<textarea cols="40" id="post_body" name="post[body]" rows="20">Foo bar&#x000A;baz</textarea>\n),
render('= text_area :post, :body', :action_view))
assert_equal(%(<pre>Foo bar\n baz</pre>\n),
assert_equal(%(<pre>Foo bar&#x000A; baz</pre>\n),
render('= content_tag "pre", "Foo bar\n baz"', :action_view))
end
@ -141,12 +141,12 @@ class HelperTest < Test::Unit::TestCase
end
def test_find_and_preserve_with_block
assert_equal("<pre>\n Foo\n Bar\n</pre>\nFoo\nBar\n",
assert_equal("<pre>&#x000A; Foo&#x000A; Bar&#x000A;</pre>\nFoo\nBar\n",
render("= find_and_preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
end
def test_preserve_with_block
assert_equal("<pre>\n Foo\n Bar\n</pre>\nFoo\nBar\n\n",
assert_equal("<pre>&#x000A; Foo&#x000A; Bar&#x000A;</pre>&#x000A;Foo&#x000A;Bar&#x000A;\n",
render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
end

View file

@ -41,14 +41,8 @@ This
\\
<p>
<pre>
This pre is pretty deeply
nested.
Does interpolation work?
This one is, too.
Nested, that is.
This pre is pretty deeply&#x000A; nested.&#x000A; Does interpolation work?&#x000A;
This one is, too.&#x000A;Nested, that is.&#x000A;&#x000A;
</pre>
</p>
<ul>

View file

@ -5,38 +5,30 @@
<textarea>BLAH
</textarea>
<div class='text_area_test_area'>
<textarea>Two
lines</textarea>
<textarea>Two&#x000A;lines</textarea>
</div>
<textarea>BLAH
</textarea>
<div class='text_area_test_area'>
<textarea>Oneline</textarea>
</div>
<textarea>BLAH
</textarea>
<textarea>BLAH&#x000A;</textarea>
<div class='text_area_test_area'>
<textarea>Two
lines</textarea>
<textarea>Two&#x000A;lines</textarea>
</div>
<textarea>BLAH
</textarea>
<textarea>BLAH&#x000A;</textarea>
<div id='flattened'>
<div class='text_area_test_area'>
<textarea>Two
lines</textarea>
<textarea>Two&#x000A;lines</textarea>
</div>
<textarea>BLAH
</textarea>
<textarea>BLAH&#x000A;</textarea>
</div>
</div>
<div class='hithere'>
Foo bar
<pre>foo bar</pre>
<pre>foo
bar</pre>
<p><pre>foo
bar</pre></p>
<pre>foo&#x000A;bar</pre>
<p><pre>foo&#x000A;bar</pre></p>
<p>
foo
bar
@ -44,13 +36,7 @@ bar</pre></p>
</div>
<div class='foo'>
13
<textarea>
a
</textarea><textarea>
b
</textarea><textarea>
c
</textarea>
<textarea>&#x000A;a&#x000A;</textarea><textarea>&#x000A;b&#x000A;</textarea><textarea>&#x000A;c&#x000A;</textarea>
</div>
<div id='whitespace_test'>
<div class='text_area_test_area'>
@ -59,89 +45,40 @@ c
<textarea>BLAH
</textarea>
<div class='text_area_test_area'>
<textarea>Two
lines</textarea>
<textarea>Two&#x000A;lines</textarea>
</div>
<textarea>BLAH
</textarea>
<div class='text_area_test_area'>
<textarea>Oneline</textarea>
</div>
<textarea>BLAH
</textarea>
<textarea>BLAH&#x000A;</textarea>
<div class='text_area_test_area'>
<textarea>Two
lines</textarea>
<textarea>Two&#x000A;lines</textarea>
</div>
<textarea>BLAH
</textarea>
<textarea>BLAH&#x000A;</textarea>
<div id='flattened'>
<div class='text_area_test_area'>
<textarea>Two
lines</textarea>
<textarea>Two&#x000A;lines</textarea>
</div>
<textarea>BLAH
</textarea>
<textarea>BLAH&#x000A;</textarea>
</div>
</div>
<div class='hithere'>
Foo bar
<pre>foo bar</pre>
<pre>foo
bar</pre>
<p><pre>foo
bar</pre></p>
<pre>foo&#x000A;bar</pre>
<p><pre>foo&#x000A;bar</pre></p>
<p>
foo
bar
</p>
<pre>
___
,o88888
,o8888888'
,:o:o:oooo. ,8O88Pd8888"
,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
, ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
, ..:.::o:ooOoOO8O888O8O,COCOO"
, . ..:.::o:ooOoOOOO8OOOOCOCO"
. ..:.::o:ooOoOoOO8O8OCCCC"o
. ..:.::o:ooooOoCoCCC"o:o
. ..:.::o:o:,cooooCo"oo:o:
` . . ..:.:cocoooo"'o:o:::'
.` . ..::ccccoc"'o:o:o:::'
:.:. ,c:cccc"':.:.:.:.:.'
..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
...:.'.:.::::"' . . . . .'
.. . ....:."' ` . . . ''
. . . ...."'
.. . ."' -hrr-
.
It's a planet!
%strong This shouldn't be bold!
___&#x000A; ,o88888&#x000A; ,o8888888'&#x000A; ,:o:o:oooo. ,8O88Pd8888"&#x000A; ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"&#x000A; ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"&#x000A; , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"&#x000A; , ..:.::o:ooOoOO8O888O8O,COCOO"&#x000A; , . ..:.::o:ooOoOOOO8OOOOCOCO"&#x000A; . ..:.::o:ooOoOoOO8O8OCCCC"o&#x000A; . ..:.::o:ooooOoCoCCC"o:o&#x000A; . ..:.::o:o:,cooooCo"oo:o:&#x000A; ` . . ..:.:cocoooo"'o:o:::'&#x000A; .` . ..::ccccoc"'o:o:o:::'&#x000A; :.:. ,c:cccc"':.:.:.:.:.'&#x000A; ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/&#x000A; ...:.'.:.::::"' . . . . .'&#x000A; .. . ....:."' ` . . . ''&#x000A; . . . ...."'&#x000A; .. . ."' -hrr-&#x000A; .&#x000A;&#x000A;&#x000A; It's a planet!&#x000A;%strong This shouldn't be bold!&#x000A;
</pre>
<strong>This should!</strong>
<textarea>
___ ___ ___ ___
/\__\ /\ \ /\__\ /\__\
/:/ / /::\ \ /::| | /:/ /
/:/__/ /:/\:\ \ /:|:| | /:/ /
/::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ /
/:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/
\/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \
\::/ / \::/ / /:/ / \:\ \
/:/ / /:/ / /:/ / \:\ \
/:/ / /:/ / /:/ / \:\__\
\/__/ \/__/ \/__/ \/__/
Many
thanks
to
http://www.network-science.de/ascii/
___ ___ ___ ___ &#x000A; /\__\ /\ \ /\__\ /\__\&#x000A; /:/ / /::\ \ /::| | /:/ /&#x000A; /:/__/ /:/\:\ \ /:|:| | /:/ / &#x000A; /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / &#x000A; /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ &#x000A; \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ &#x000A; \::/ / \::/ / /:/ / \:\ \ &#x000A; /:/ / /:/ / /:/ / \:\ \ &#x000A; /:/ / /:/ / /:/ / \:\__\&#x000A; \/__/ \/__/ \/__/ \/__/&#x000A;&#x000A; Many&#x000A; thanks&#x000A; to&#x000A; http://www.network-science.de/ascii/&#x000A;
<strong>indeed!</strong>
</textarea>
</div>
@ -149,14 +86,9 @@ bar</pre></p>
13
</div>
<pre>
__ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|
__ ______ __ ______&#x000A;.----.| |--.|__ |.----.| |--..--------.| __ |&#x000A;| __|| ||__ || __|| < | || __ |&#x000A;|____||__|__||______||____||__|__||__|__|__||______|&#x000A;
</pre>
<pre>
foo
foo&#x000A;
bar
</pre>