Allow filters without nested text.

This commit is contained in:
Nathan Weizenbaum 2008-04-18 11:37:34 -07:00
parent 70778c95eb
commit fd5fafc997
2 changed files with 10 additions and 2 deletions

View File

@ -668,7 +668,6 @@ END
# Starts a filtered block.
def start_filtered(name)
raise HamlError.new("Invalid filter name \":#{name}\"") unless name =~ /^\w+$/
raise SyntaxError.new('Filters must have nested text.') unless @block_opened
unless filter = options[:filters][name]
if filter == 'redcloth' || filter == 'markdown' || filter == 'textile'

View File

@ -5,7 +5,6 @@ class EngineTest < Test::Unit::TestCase
EXCEPTION_MAP = {
"!!!\n a" => "Illegal Nesting: Nesting within a header command is illegal.",
"a\n b" => "Illegal Nesting: Nesting within plain text is illegal.",
":a" => "Filters must have nested text.",
"/ a\n b" => "Illegal Nesting: Nesting within a tag that already has content is illegal.",
"% a" => 'Invalid tag: "% a"',
"%p a\n b" => "Illegal Nesting: Content can't be both given on the same line as %p and nested within it.",
@ -439,6 +438,16 @@ class EngineTest < Test::Unit::TestCase
end
end
def test_empty_filter
assert_equal(<<END, render(':javascript'))
<script type='text/javascript'>
//<![CDATA[
//]]>
</script>
END
end
def test_local_assigns_dont_modify_class
assert_equal("bar\n", render("= foo", :locals => {:foo => 'bar'}))
assert_equal(nil, defined?(foo))