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

String literals now can't be checked for their multi-line status.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@51 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
hcatlin 2006-09-29 19:20:53 +00:00
parent 045d1ba9e2
commit 45fd5d152e
3 changed files with 11 additions and 12 deletions

View file

@ -7,8 +7,10 @@ module Haml #:nodoc:
# 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
@ -42,8 +44,8 @@ module Haml #:nodoc:
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 '%'
@ -63,21 +65,16 @@ module Haml #:nodoc:
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

View file

@ -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>

View file

@ -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("|") |