[Haml] [HTML] Fix an ERB-parsing bug.
Hpricot was considering <haml:*> tags to have no allowed children in HTML. This meant that in certain contexts, a child tag was forced to be a child of a different element. Now we tell Hpricot that <haml:*> tags are allowed everywhere and can have any other tags as children.
This commit is contained in:
parent
d81d18f1b1
commit
fa6a198315
|
@ -3,6 +3,11 @@
|
|||
* Table of contents
|
||||
{:toc}
|
||||
|
||||
## 3.0.16 (Unreleased)
|
||||
|
||||
* Fix an html2haml ERB-parsing bug where ERB blocks were occasionally
|
||||
left without indentation in Haml.
|
||||
|
||||
## 3.0.15
|
||||
|
||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.15).
|
||||
|
|
|
@ -100,6 +100,23 @@ end
|
|||
|
||||
require 'hpricot'
|
||||
|
||||
# @private
|
||||
HAML_TAGS = %w[haml:block haml:loud haml:silent]
|
||||
|
||||
Hpricot::ElementContent.keys.each do |k|
|
||||
HAML_TAGS.each do |el|
|
||||
val = Hpricot::ElementContent[k]
|
||||
val[el.hash] = true if val.is_a?(Hash)
|
||||
end
|
||||
end
|
||||
|
||||
HAML_TAGS.each do |t|
|
||||
Hpricot::ElementContent[t] = {}
|
||||
Hpricot::ElementContent.keys.each do |key|
|
||||
Hpricot::ElementContent[t][key.hash] = true
|
||||
end
|
||||
end
|
||||
|
||||
module Haml
|
||||
# Converts HTML documents into Haml templates.
|
||||
# Depends on [Hpricot](http://github.com/whymirror/hpricot) for HTML parsing.
|
||||
|
|
|
@ -405,6 +405,22 @@ HAML
|
|||
<% ensure %>
|
||||
<p>c</p>
|
||||
<% end %>
|
||||
ERB
|
||||
end
|
||||
|
||||
# Regression
|
||||
|
||||
def test_tag_inside_block
|
||||
assert_equal(<<HAML.rstrip, render_erb(<<ERB))
|
||||
%table
|
||||
- foo.each do
|
||||
%tr
|
||||
HAML
|
||||
<table>
|
||||
<% foo.each do %>
|
||||
<tr></tr>
|
||||
<% end %>
|
||||
</table>
|
||||
ERB
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue