mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Fix a couple bugs with using "-end" in strings.
This commit is contained in:
parent
3a70a87785
commit
021d0b729f
3 changed files with 23 additions and 3 deletions
|
@ -10,6 +10,8 @@
|
|||
|
||||
* Fixed CSS id concatenation when a numeric id is given as an attribute.
|
||||
(thanks to [Norman Clarke](http://blog.njclarke.com/)).
|
||||
|
||||
* Fixed a couple bugs with using "-end" in strings.
|
||||
|
||||
## [2.2.4](http://github.com/nex3/haml/commit/2.2.4)
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ module Haml
|
|||
#
|
||||
# The block is ended after <tt>%p no!</tt>, because <tt>else</tt>
|
||||
# is a member of this array.
|
||||
MID_BLOCK_KEYWORD_REGEX = /-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
|
||||
MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
|
||||
|
||||
# The Regex that matches a Doctype command.
|
||||
DOCTYPE_REGEX = /(\d\.\d)?[\s]*([a-z]*)/i
|
||||
|
@ -228,9 +228,9 @@ END
|
|||
newline_now
|
||||
|
||||
# Handle stuff like - end.join("|")
|
||||
@to_close_stack.first << false if text =~ /-\s*end\b/ && !block_opened?
|
||||
@to_close_stack.first << false if text =~ /^-\s*end\b/ && !block_opened?
|
||||
|
||||
case_stmt = text =~ /-\s*case\b/
|
||||
case_stmt = text =~ /^-\s*case\b/
|
||||
block = block_opened? && !mid_block_keyword?(text)
|
||||
push_and_tabulate([:script]) if block || case_stmt
|
||||
push_and_tabulate(:nil) if block && case_stmt
|
||||
|
|
|
@ -468,6 +468,24 @@ HTML
|
|||
HAML
|
||||
end
|
||||
|
||||
def test_silent_script_with_hyphen_case
|
||||
assert_equal("", render("- 'foo-case-bar-case'"))
|
||||
end
|
||||
|
||||
def test_silent_script_with_hyphen_end
|
||||
assert_equal("", render("- 'foo-end-bar-end'"))
|
||||
end
|
||||
|
||||
def test_silent_script_with_hyphen_end_and_block
|
||||
assert_equal(<<HTML, render(<<HAML))
|
||||
<p>foo-end</p>
|
||||
<p>bar-end</p>
|
||||
HTML
|
||||
- "foo-end-bar-end".gsub(/\\w+-end/) do |s|
|
||||
%p= s
|
||||
HAML
|
||||
end
|
||||
|
||||
# HTML escaping tests
|
||||
|
||||
def test_ampersand_equals_should_escape
|
||||
|
|
Loading…
Add table
Reference in a new issue