haml 3.1.0.alpha.12 → 3.1.0.alpha.14
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of haml might be problematic. Click here for more details.
- data/EDGE_GEM_VERSION +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/haml/filters.rb +14 -2
- data/lib/haml/precompiler.rb +8 -6
- data/lib/haml/util.rb +5 -3
- data/test/haml/engine_test.rb +51 -0
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0.alpha.
|
1
|
+
3.1.0.alpha.14
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.0.alpha.
|
1
|
+
3.1.0.alpha.14
|
data/lib/haml/filters.rb
CHANGED
@@ -200,8 +200,14 @@ module Haml
|
|
200
200
|
|
201
201
|
# @see Base#render_with_options
|
202
202
|
def render_with_options(text, options)
|
203
|
+
if options[:format] == :html5
|
204
|
+
type = ''
|
205
|
+
else
|
206
|
+
type = " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
|
207
|
+
end
|
208
|
+
|
203
209
|
<<END
|
204
|
-
<script
|
210
|
+
<script#{type}>
|
205
211
|
//<![CDATA[
|
206
212
|
#{text.rstrip.gsub("\n", "\n ")}
|
207
213
|
//]]>
|
@@ -217,8 +223,14 @@ END
|
|
217
223
|
|
218
224
|
# @see Base#render_with_options
|
219
225
|
def render_with_options(text, options)
|
226
|
+
if options[:format] == :html5
|
227
|
+
type = ''
|
228
|
+
else
|
229
|
+
type = " type=#{options[:attr_wrapper]}text/css#{options[:attr_wrapper]}"
|
230
|
+
end
|
231
|
+
|
220
232
|
<<END
|
221
|
-
<style
|
233
|
+
<style#{type}>
|
222
234
|
/*<![CDATA[*/
|
223
235
|
#{text.rstrip.gsub("\n", "\n ")}
|
224
236
|
/*]]>*/
|
data/lib/haml/precompiler.rb
CHANGED
@@ -336,12 +336,14 @@ END
|
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
339
|
+
unless str.empty?
|
340
|
+
@precompiled <<
|
341
|
+
if @options[:ugly]
|
342
|
+
"_hamlout.buffer << \"#{str}\";"
|
343
|
+
else
|
344
|
+
"_hamlout.push_text(\"#{str}\", #{mtabs}, #{@dont_tab_up_next_text.inspect});"
|
345
|
+
end
|
346
|
+
end
|
345
347
|
@precompiled << "\n" * newlines
|
346
348
|
@to_merge = []
|
347
349
|
@dont_tab_up_next_text = false
|
data/lib/haml/util.rb
CHANGED
@@ -120,10 +120,12 @@ module Haml
|
|
120
120
|
# @example
|
121
121
|
# merge_adjacent_strings([1, "foo", "bar", 2, "baz"])
|
122
122
|
# #=> [1, "foobar", 2, "baz"]
|
123
|
-
# @param
|
123
|
+
# @param arr [Array]
|
124
124
|
# @return [Array] The enumerable with strings merged
|
125
|
-
def merge_adjacent_strings(
|
126
|
-
|
125
|
+
def merge_adjacent_strings(arr)
|
126
|
+
# Optimize for the common case of one element
|
127
|
+
return arr if arr.size < 2
|
128
|
+
arr.inject([]) do |a, e|
|
127
129
|
if e.is_a?(String)
|
128
130
|
if a.last.is_a?(String)
|
129
131
|
a.last << e
|
data/test/haml/engine_test.rb
CHANGED
@@ -86,6 +86,7 @@ MESSAGE
|
|
86
86
|
"foo\n:plain\n 1\n 2\n 3\#{''}\n4\n- raise 'foo'" => ["foo", 7],
|
87
87
|
"foo\n:plain\n 1\n 2\n \#{raise 'foo'}" => ["foo", 5],
|
88
88
|
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
|
89
|
+
"- case 1\n\n- when 1\n - raise 'foo'" => ["foo", 4],
|
89
90
|
}
|
90
91
|
|
91
92
|
User = Struct.new('User', :id)
|
@@ -641,6 +642,32 @@ HTML
|
|
641
642
|
HAML
|
642
643
|
end
|
643
644
|
|
645
|
+
def test_html5_javascript_filter
|
646
|
+
assert_equal(<<HTML, render(<<HAML, :format => :html5))
|
647
|
+
<script>
|
648
|
+
//<![CDATA[
|
649
|
+
foo bar
|
650
|
+
//]]>
|
651
|
+
</script>
|
652
|
+
HTML
|
653
|
+
:javascript
|
654
|
+
foo bar
|
655
|
+
HAML
|
656
|
+
end
|
657
|
+
|
658
|
+
def test_html5_css_filter
|
659
|
+
assert_equal(<<HTML, render(<<HAML, :format => :html5))
|
660
|
+
<style>
|
661
|
+
/*<![CDATA[*/
|
662
|
+
foo bar
|
663
|
+
/*]]>*/
|
664
|
+
</style>
|
665
|
+
HTML
|
666
|
+
:css
|
667
|
+
foo bar
|
668
|
+
HAML
|
669
|
+
end
|
670
|
+
|
644
671
|
def test_erb_filter_with_multiline_expr
|
645
672
|
assert_equal(<<HTML, render(<<HAML))
|
646
673
|
foobarbaz
|
@@ -774,6 +801,30 @@ HTML
|
|
774
801
|
HAML
|
775
802
|
end
|
776
803
|
|
804
|
+
def test_case_with_newline_after_case
|
805
|
+
assert_equal(<<HTML, render(<<HAML))
|
806
|
+
foo
|
807
|
+
HTML
|
808
|
+
- case 1
|
809
|
+
|
810
|
+
- when 1
|
811
|
+
foo
|
812
|
+
- when 2
|
813
|
+
bar
|
814
|
+
HAML
|
815
|
+
|
816
|
+
assert_equal(<<HTML, render(<<HAML))
|
817
|
+
bar
|
818
|
+
HTML
|
819
|
+
- case 2
|
820
|
+
|
821
|
+
- when 1
|
822
|
+
foo
|
823
|
+
- when 2
|
824
|
+
bar
|
825
|
+
HAML
|
826
|
+
end
|
827
|
+
|
777
828
|
def test_escape_html_with_interpolated_if_statement
|
778
829
|
assert_equal(<<HTML, render(<<HAML, :escape_html => true))
|
779
830
|
foo,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.alpha.
|
4
|
+
version: 3.1.0.alpha.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-
|
13
|
+
date: 2010-10-03 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|