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:
parent
0d4010cbaa
commit
97de8a5459
8 changed files with 32 additions and 117 deletions
|
@ -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
|
||||
|
|
|
@ -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('
', "\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)
|
||||
|
|
|
@ -171,7 +171,7 @@ END
|
|||
@haml_buffer = buffer.upper
|
||||
end
|
||||
|
||||
buffer.result
|
||||
buffer.buffer
|
||||
end
|
||||
alias_method :to_html, :render
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -121,10 +121,10 @@ END
|
|||
end
|
||||
|
||||
def test_textareas
|
||||
assert_equal("<textarea>Foo\n bar\n baz</textarea>\n",
|
||||
assert_equal("<textarea>Foo
 bar
 baz</textarea>\n",
|
||||
render('%textarea= "Foo\n bar\n baz"'))
|
||||
|
||||
assert_equal("<pre>Foo\n bar\n baz</pre>\n",
|
||||
assert_equal("<pre>Foo
 bar
 baz</pre>\n",
|
||||
render('%pre= "Foo\n bar\n baz"'))
|
||||
|
||||
assert_equal("<textarea>#{'a' * 100}</textarea>\n",
|
||||
|
|
|
@ -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
Bar
 Baz
 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
baz</textarea>\n),
|
||||
render('= text_area :post, :body', :action_view))
|
||||
|
||||
assert_equal(%(<pre>Foo bar\n baz</pre>\n),
|
||||
assert_equal(%(<pre>Foo bar
 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>
 Foo
 Bar
</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>
 Foo
 Bar
</pre>
Foo
Bar
\n",
|
||||
render("= preserve do\n %pre\n Foo\n Bar\n Foo\n Bar"))
|
||||
end
|
||||
|
||||
|
|
|
@ -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
 nested.
 Does interpolation work?

|
||||
This one is, too.
Nested, that is.


|
||||
</pre>
|
||||
</p>
|
||||
<ul>
|
||||
|
|
|
@ -5,38 +5,30 @@
|
|||
<textarea>BLAH
|
||||
</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
|
||||
lines</textarea>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Oneline</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<textarea>BLAH
</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
|
||||
lines</textarea>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<textarea>BLAH
</textarea>
|
||||
<div id='flattened'>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
|
||||
lines</textarea>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<textarea>BLAH
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class='hithere'>
|
||||
Foo bar
|
||||
<pre>foo bar</pre>
|
||||
<pre>foo
|
||||
bar</pre>
|
||||
<p><pre>foo
|
||||
bar</pre></p>
|
||||
<pre>foo
bar</pre>
|
||||
<p><pre>foo
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>
a
</textarea><textarea>
b
</textarea><textarea>
c
</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
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Oneline</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<textarea>BLAH
</textarea>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
|
||||
lines</textarea>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<textarea>BLAH
</textarea>
|
||||
<div id='flattened'>
|
||||
<div class='text_area_test_area'>
|
||||
<textarea>Two
|
||||
lines</textarea>
|
||||
<textarea>Two
lines</textarea>
|
||||
</div>
|
||||
<textarea>BLAH
|
||||
</textarea>
|
||||
<textarea>BLAH
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class='hithere'>
|
||||
Foo bar
|
||||
<pre>foo bar</pre>
|
||||
<pre>foo
|
||||
bar</pre>
|
||||
<p><pre>foo
|
||||
bar</pre></p>
|
||||
<pre>foo
bar</pre>
|
||||
<p><pre>foo
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!
|
||||
|
||||
___
 ,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!

|
||||
</pre>
|
||||
<strong>This should!</strong>
|
||||
<textarea>
|
||||
___ ___ ___ ___
|
||||
/\__\ /\ \ /\__\ /\__\
|
||||
/:/ / /::\ \ /::| | /:/ /
|
||||
/:/__/ /:/\:\ \ /:|:| | /:/ /
|
||||
/::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ /
|
||||
/:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/
|
||||
\/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \
|
||||
\::/ / \::/ / /:/ / \:\ \
|
||||
/:/ / /:/ / /:/ / \:\ \
|
||||
/:/ / /:/ / /:/ / \:\__\
|
||||
\/__/ \/__/ \/__/ \/__/
|
||||
|
||||
Many
|
||||
thanks
|
||||
to
|
||||
http://www.network-science.de/ascii/
|
||||
|
||||
___ ___ ___ ___ 
 /\__\ /\ \ /\__\ /\__\
 /:/ / /::\ \ /::| | /:/ /
 /:/__/ /:/\:\ \ /:|:| | /:/ / 
 /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / 
 /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ 
 \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ 
 \::/ / \::/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\ \ 
 /:/ / /:/ / /:/ / \:\__\
 \/__/ \/__/ \/__/ \/__/

 Many
 thanks
 to
 http://www.network-science.de/ascii/

|
||||
<strong>indeed!</strong>
|
||||
</textarea>
|
||||
</div>
|
||||
|
@ -149,14 +86,9 @@ bar</pre></p>
|
|||
13
|
||||
</div>
|
||||
<pre>
|
||||
__ ______ __ ______
|
||||
.----.| |--.|__ |.----.| |--..--------.| __ |
|
||||
| __|| ||__ || __|| < | || __ |
|
||||
|____||__|__||______||____||__|__||__|__|__||______|
|
||||
|
||||
__ ______ __ ______
.----.| |--.|__ |.----.| |--..--------.| __ |
| __|| ||__ || __|| < | || __ |
|____||__|__||______||____||__|__||__|__|__||______|

|
||||
</pre>
|
||||
<pre>
|
||||
foo
|
||||
|
||||
foo

|
||||
bar
|
||||
</pre>
|
||||
|
|
Loading…
Add table
Reference in a new issue