Skip to content

Commit

Permalink
String literals now can't be checked for their multi-line status.
Browse files Browse the repository at this point in the history
git-svn-id: svn://hamptoncatlin.com/haml/trunk@51 7063305b-7217-0410-af8c-cdc13e5119b9
  • Loading branch information
hcatlin committed Sep 29, 2006
1 parent 045d1ba commit 45fd5d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 7 additions & 10 deletions lib/haml/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class Engine
# Set the maximum length for a line to be considered a one-liner
# Lines <= the maximum will be rendered on one line,
# i.e. <tt><p>Hello world</p></tt>
ONE_LINER_LENGTH = 50
ONE_LINER_LENGTH = 50
SPECIAL_CHARACTERS = %w(# . = ~ % /).collect { |c| c[0] }
MULTILINE_CHAR_VALUE = '|'[0]
MULTILINE_STARTERS = SPECIAL_CHARACTERS - ["/"[0]]

def initialize(template, action_view=nil)
@view = action_view
Expand Down Expand Up @@ -42,8 +44,8 @@ def process_line(count, line)
if count <= @to_close_queue.size && @to_close_queue.size > 0
(@to_close_queue.size - count).times { close_tag }
end
case line.first

case line[0..0]
when '.', '#'
render_div(line)
when '%'
Expand All @@ -63,21 +65,16 @@ def process_line(count, line)

def handle_multiline(count, line)
# Multilines are denoting by ending with a `|` (124)
if @multiline_buffer && line[-1] == MULTILINE_CHAR_VALUE

if (line[-1] == MULTILINE_CHAR_VALUE) && @multiline_buffer
# A multiline string is active, and is being continued
@multiline_buffer += line[0...-1]
supress_render = true

elsif line[-1] == MULTILINE_CHAR_VALUE

elsif (line[-1] == MULTILINE_CHAR_VALUE) && (MULTILINE_STARTERS.include? line[0])
# A multiline string has just been activated, start adding the lines
@multiline_buffer = line[0...-1]
@multiline_count = count
supress_render = true

elsif @multiline_buffer

# A multiline string has just ended, make line into the result
process_line(@multiline_count, @multiline_buffer)
@multiline_buffer = nil
Expand Down
3 changes: 2 additions & 1 deletion test/results/standard.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
20
</div>
<div id='body'> Quotes should be loved! Just like people!</div>
Wow.|
<p>
Holy cow multiline tags! A pipe (|) even!
Wow.
PipesIgnored|PipesIgnored|PipesIgnored|
1|2|3
</p>
<div class='of_divs_with_underscore' id='combo'>with this text</div>
Expand Down
3 changes: 2 additions & 1 deletion test/templates/standard.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
The question is if this would translate! Ahah!
= 1 + 9 + 8 + 2 #numbers should work and this should be ignored
#body= " Quotes should be loved! Just like people!"
Wow.|
%p
= "Holy cow " + |
"multiline " + |
"tags! " + |
"A pipe (|) even!" |
Wow.
= [1, 2, 3].collect { |n| "PipesIgnored|" }
= [1, 2, 3].collect { |n| |
n.to_s |
}.join("|") |
Expand Down

0 comments on commit 45fd5d1

Please sign in to comment.