Skip to content

Commit

Permalink
addresses issue 223. if output call is commented out don't output tag
Browse files Browse the repository at this point in the history
  • Loading branch information
stonean committed Jan 13, 2012
1 parent 0b217b8 commit 901e1c7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/slim/parser.rb
Expand Up @@ -295,14 +295,19 @@ def parse_tag(tag)
@stacks << content
parse_tag($1)
@stacks.delete_at(i)
when /\A\s*=(=?)('?)/
# Handle output code
block = [:multi]
@line = $'
content = [:slim, :output, $1 != '=', parse_broken_line, block]
tag << content
@stacks.last << [:static, ' '] unless $2.empty?
@stacks << block
when /\A\s*=(=?)('?)(\s*#)?/
if $3
# Commented output call so don't output tag
@stacks.last.pop
else
# Handle output code
block = [:multi]
@line = $'
content = [:slim, :output, $1 != '=', parse_broken_line, block]
tag << content
@stacks.last << [:static, ' '] unless $2.empty?
@stacks << block
end
when /\A\s*\//
# Closed tag. Do nothing
when /\A\s*\Z/
Expand Down
12 changes: 12 additions & 0 deletions test/slim/test_code_output.rb
Expand Up @@ -156,4 +156,16 @@ def test_render_with_no_trailing_character

assert_html '<p>Hello World from @env</p>', source
end

def test_commented_out_call
source = %q{
table
tr
td Name
td = #hello_world
td =# not_gonna_be_called
}

assert_html '<table><tr><td>Name</td></tr></table>', source
end
end

0 comments on commit 901e1c7

Please sign in to comment.