mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Don't Add type attrs for filters under HTML5.
Closes gh-283
This commit is contained in:
parent
c6c7b96246
commit
bc4977f2a7
3 changed files with 43 additions and 2 deletions
|
@ -5,6 +5,9 @@
|
|||
|
||||
## 3.2.0 (Unreleased)
|
||||
|
||||
* Don't add a `type` attribute to `<script>` and `<style>` tags generated by filters
|
||||
when `:format` is set to `:html5`.
|
||||
|
||||
### Backwards Incompatibilities -- Must Read!
|
||||
|
||||
* Get rid of the `--rails` flag for the `haml` executable.
|
||||
|
|
|
@ -200,8 +200,14 @@ module Haml
|
|||
|
||||
# @see Base#render_with_options
|
||||
def render_with_options(text, options)
|
||||
if options[:format] == :html5
|
||||
type = ''
|
||||
else
|
||||
type = " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
|
||||
end
|
||||
|
||||
<<END
|
||||
<script type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}>
|
||||
<script#{type}>
|
||||
//<![CDATA[
|
||||
#{text.rstrip.gsub("\n", "\n ")}
|
||||
//]]>
|
||||
|
@ -217,8 +223,14 @@ END
|
|||
|
||||
# @see Base#render_with_options
|
||||
def render_with_options(text, options)
|
||||
if options[:format] == :html5
|
||||
type = ''
|
||||
else
|
||||
type = " type=#{options[:attr_wrapper]}text/css#{options[:attr_wrapper]}"
|
||||
end
|
||||
|
||||
<<END
|
||||
<style type=#{options[:attr_wrapper]}text/css#{options[:attr_wrapper]}>
|
||||
<style#{type}>
|
||||
/*<![CDATA[*/
|
||||
#{text.rstrip.gsub("\n", "\n ")}
|
||||
/*]]>*/
|
||||
|
|
|
@ -641,6 +641,32 @@ HTML
|
|||
HAML
|
||||
end
|
||||
|
||||
def test_html5_javascript_filter
|
||||
assert_equal(<<HTML, render(<<HAML, :format => :html5))
|
||||
<script>
|
||||
//<![CDATA[
|
||||
foo bar
|
||||
//]]>
|
||||
</script>
|
||||
HTML
|
||||
:javascript
|
||||
foo bar
|
||||
HAML
|
||||
end
|
||||
|
||||
def test_html5_css_filter
|
||||
assert_equal(<<HTML, render(<<HAML, :format => :html5))
|
||||
<style>
|
||||
/*<![CDATA[*/
|
||||
foo bar
|
||||
/*]]>*/
|
||||
</style>
|
||||
HTML
|
||||
:css
|
||||
foo bar
|
||||
HAML
|
||||
end
|
||||
|
||||
def test_erb_filter_with_multiline_expr
|
||||
assert_equal(<<HTML, render(<<HAML))
|
||||
foobarbaz
|
||||
|
|
Loading…
Add table
Reference in a new issue