haml 3.0.25 → 3.1.0.alpha.2
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/.yardopts +1 -1
- data/CONTRIBUTING +0 -1
- data/EDGE_GEM_VERSION +1 -0
- data/MIT-LICENSE +1 -1
- data/README.md +10 -175
- data/Rakefile +56 -84
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/init.rb +1 -1
- data/lib/haml.rb +14 -12
- data/lib/haml/engine.rb +1 -1
- data/lib/haml/exec.rb +19 -316
- data/lib/haml/helpers/action_view_extensions.rb +1 -1
- data/lib/haml/html.rb +69 -76
- data/lib/haml/precompiler.rb +34 -41
- data/lib/haml/railtie.rb +4 -6
- data/lib/haml/template/plugin.rb +6 -16
- data/lib/haml/util.rb +91 -107
- data/lib/haml/version.rb +7 -0
- data/test/benchmark.rb +2 -9
- data/test/haml/engine_test.rb +195 -92
- data/test/haml/html2haml/erb_tests.rb +0 -14
- data/test/haml/util_test.rb +32 -0
- data/test/test_helper.rb +0 -39
- metadata +96 -324
- data/bin/css2sass +0 -13
- data/bin/sass +0 -8
- data/bin/sass-convert +0 -7
- data/extra/haml-mode.el +0 -753
- data/extra/sass-mode.el +0 -207
- data/lib/haml/util/subset_map.rb +0 -101
- data/lib/sass.rb +0 -29
- data/lib/sass/callbacks.rb +0 -52
- data/lib/sass/css.rb +0 -294
- data/lib/sass/engine.rb +0 -720
- data/lib/sass/environment.rb +0 -143
- data/lib/sass/error.rb +0 -198
- data/lib/sass/files.rb +0 -160
- data/lib/sass/less.rb +0 -382
- data/lib/sass/plugin.rb +0 -279
- data/lib/sass/plugin/configuration.rb +0 -221
- data/lib/sass/plugin/generic.rb +0 -15
- data/lib/sass/plugin/merb.rb +0 -37
- data/lib/sass/plugin/rack.rb +0 -47
- data/lib/sass/plugin/rails.rb +0 -32
- data/lib/sass/plugin/staleness_checker.rb +0 -123
- data/lib/sass/repl.rb +0 -58
- data/lib/sass/script.rb +0 -63
- data/lib/sass/script/bool.rb +0 -18
- data/lib/sass/script/color.rb +0 -491
- data/lib/sass/script/css_lexer.rb +0 -29
- data/lib/sass/script/css_parser.rb +0 -31
- data/lib/sass/script/funcall.rb +0 -77
- data/lib/sass/script/functions.rb +0 -861
- data/lib/sass/script/interpolation.rb +0 -70
- data/lib/sass/script/lexer.rb +0 -337
- data/lib/sass/script/literal.rb +0 -236
- data/lib/sass/script/node.rb +0 -112
- data/lib/sass/script/number.rb +0 -423
- data/lib/sass/script/operation.rb +0 -95
- data/lib/sass/script/parser.rb +0 -401
- data/lib/sass/script/string.rb +0 -67
- data/lib/sass/script/string_interpolation.rb +0 -93
- data/lib/sass/script/unary_operation.rb +0 -57
- data/lib/sass/script/variable.rb +0 -48
- data/lib/sass/scss.rb +0 -17
- data/lib/sass/scss/css_parser.rb +0 -46
- data/lib/sass/scss/parser.rb +0 -855
- data/lib/sass/scss/rx.rb +0 -126
- data/lib/sass/scss/sass_parser.rb +0 -11
- data/lib/sass/scss/script_lexer.rb +0 -15
- data/lib/sass/scss/script_parser.rb +0 -25
- data/lib/sass/scss/static_parser.rb +0 -40
- data/lib/sass/selector.rb +0 -361
- data/lib/sass/selector/abstract_sequence.rb +0 -62
- data/lib/sass/selector/comma_sequence.rb +0 -82
- data/lib/sass/selector/sequence.rb +0 -237
- data/lib/sass/selector/simple.rb +0 -113
- data/lib/sass/selector/simple_sequence.rb +0 -136
- data/lib/sass/tree/charset_node.rb +0 -37
- data/lib/sass/tree/comment_node.rb +0 -128
- data/lib/sass/tree/debug_node.rb +0 -36
- data/lib/sass/tree/directive_node.rb +0 -75
- data/lib/sass/tree/extend_node.rb +0 -65
- data/lib/sass/tree/for_node.rb +0 -55
- data/lib/sass/tree/if_node.rb +0 -69
- data/lib/sass/tree/import_node.rb +0 -102
- data/lib/sass/tree/mixin_def_node.rb +0 -48
- data/lib/sass/tree/mixin_node.rb +0 -111
- data/lib/sass/tree/node.rb +0 -464
- data/lib/sass/tree/prop_node.rb +0 -220
- data/lib/sass/tree/root_node.rb +0 -163
- data/lib/sass/tree/rule_node.rb +0 -261
- data/lib/sass/tree/variable_node.rb +0 -39
- data/lib/sass/tree/warn_node.rb +0 -42
- data/lib/sass/tree/while_node.rb +0 -36
- data/test/haml/util/subset_map_test.rb +0 -91
- data/test/sass/callbacks_test.rb +0 -61
- data/test/sass/conversion_test.rb +0 -1218
- data/test/sass/css2sass_test.rb +0 -364
- data/test/sass/data/hsl-rgb.txt +0 -319
- data/test/sass/engine_test.rb +0 -2267
- data/test/sass/extend_test.rb +0 -1348
- data/test/sass/functions_test.rb +0 -556
- data/test/sass/less_conversion_test.rb +0 -653
- data/test/sass/more_results/more1.css +0 -9
- data/test/sass/more_results/more1_with_line_comments.css +0 -26
- data/test/sass/more_results/more_import.css +0 -29
- data/test/sass/more_templates/_more_partial.sass +0 -2
- data/test/sass/more_templates/more1.sass +0 -23
- data/test/sass/more_templates/more_import.sass +0 -11
- data/test/sass/plugin_test.rb +0 -433
- data/test/sass/results/alt.css +0 -4
- data/test/sass/results/basic.css +0 -9
- data/test/sass/results/compact.css +0 -5
- data/test/sass/results/complex.css +0 -86
- data/test/sass/results/compressed.css +0 -1
- data/test/sass/results/expanded.css +0 -19
- data/test/sass/results/import.css +0 -31
- data/test/sass/results/import_charset.css +0 -4
- data/test/sass/results/import_charset_1_8.css +0 -4
- data/test/sass/results/import_charset_ibm866.css +0 -4
- data/test/sass/results/line_numbers.css +0 -49
- data/test/sass/results/mixins.css +0 -95
- data/test/sass/results/multiline.css +0 -24
- data/test/sass/results/nested.css +0 -22
- data/test/sass/results/options.css +0 -1
- data/test/sass/results/parent_ref.css +0 -13
- data/test/sass/results/script.css +0 -16
- data/test/sass/results/scss_import.css +0 -31
- data/test/sass/results/scss_importee.css +0 -2
- data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
- data/test/sass/results/subdir/subdir.css +0 -3
- data/test/sass/results/units.css +0 -11
- data/test/sass/results/warn.css +0 -0
- data/test/sass/results/warn_imported.css +0 -0
- data/test/sass/script_conversion_test.rb +0 -314
- data/test/sass/script_test.rb +0 -470
- data/test/sass/scss/css_test.rb +0 -916
- data/test/sass/scss/rx_test.rb +0 -156
- data/test/sass/scss/scss_test.rb +0 -1122
- data/test/sass/scss/test_helper.rb +0 -37
- data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
- data/test/sass/templates/_imported_charset_utf8.sass +0 -4
- data/test/sass/templates/_partial.sass +0 -2
- data/test/sass/templates/alt.sass +0 -16
- data/test/sass/templates/basic.sass +0 -23
- data/test/sass/templates/bork1.sass +0 -2
- data/test/sass/templates/bork2.sass +0 -2
- data/test/sass/templates/bork3.sass +0 -2
- data/test/sass/templates/bork4.sass +0 -2
- data/test/sass/templates/compact.sass +0 -17
- data/test/sass/templates/complex.sass +0 -305
- data/test/sass/templates/compressed.sass +0 -15
- data/test/sass/templates/expanded.sass +0 -17
- data/test/sass/templates/import.sass +0 -12
- data/test/sass/templates/import_charset.sass +0 -7
- data/test/sass/templates/import_charset_1_8.sass +0 -4
- data/test/sass/templates/import_charset_ibm866.sass +0 -9
- data/test/sass/templates/importee.less +0 -2
- data/test/sass/templates/importee.sass +0 -19
- data/test/sass/templates/line_numbers.sass +0 -13
- data/test/sass/templates/mixin_bork.sass +0 -5
- data/test/sass/templates/mixins.sass +0 -76
- data/test/sass/templates/multiline.sass +0 -20
- data/test/sass/templates/nested.sass +0 -25
- data/test/sass/templates/nested_bork1.sass +0 -2
- data/test/sass/templates/nested_bork2.sass +0 -2
- data/test/sass/templates/nested_bork3.sass +0 -2
- data/test/sass/templates/nested_bork4.sass +0 -2
- data/test/sass/templates/nested_mixin_bork.sass +0 -6
- data/test/sass/templates/options.sass +0 -2
- data/test/sass/templates/parent_ref.sass +0 -25
- data/test/sass/templates/script.sass +0 -101
- data/test/sass/templates/scss_import.scss +0 -11
- data/test/sass/templates/scss_importee.scss +0 -1
- data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
- data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
- data/test/sass/templates/subdir/subdir.sass +0 -6
- data/test/sass/templates/units.sass +0 -11
- data/test/sass/templates/warn.sass +0 -3
- data/test/sass/templates/warn_imported.sass +0 -4
- data/vendor/fssm/LICENSE +0 -20
- data/vendor/fssm/README.markdown +0 -55
- data/vendor/fssm/Rakefile +0 -59
- data/vendor/fssm/VERSION.yml +0 -5
- data/vendor/fssm/example.rb +0 -9
- data/vendor/fssm/fssm.gemspec +0 -77
- data/vendor/fssm/lib/fssm.rb +0 -33
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +0 -36
- data/vendor/fssm/lib/fssm/backends/inotify.rb +0 -26
- data/vendor/fssm/lib/fssm/backends/polling.rb +0 -25
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +0 -131
- data/vendor/fssm/lib/fssm/monitor.rb +0 -26
- data/vendor/fssm/lib/fssm/path.rb +0 -91
- data/vendor/fssm/lib/fssm/pathname.rb +0 -502
- data/vendor/fssm/lib/fssm/state/directory.rb +0 -57
- data/vendor/fssm/lib/fssm/state/file.rb +0 -24
- data/vendor/fssm/lib/fssm/support.rb +0 -63
- data/vendor/fssm/lib/fssm/tree.rb +0 -176
- data/vendor/fssm/profile/prof-cache.rb +0 -40
- data/vendor/fssm/profile/prof-fssm-pathname.html +0 -1231
- data/vendor/fssm/profile/prof-pathname.rb +0 -68
- data/vendor/fssm/profile/prof-plain-pathname.html +0 -988
- data/vendor/fssm/profile/prof.html +0 -2379
- data/vendor/fssm/spec/path_spec.rb +0 -75
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +0 -14
data/lib/haml/version.rb
CHANGED
@@ -99,4 +99,11 @@ module Haml
|
|
99
99
|
return nil
|
100
100
|
end
|
101
101
|
end
|
102
|
+
|
103
|
+
extend Haml::Version
|
104
|
+
|
105
|
+
# A string representing the version of Haml.
|
106
|
+
# A more fine-grained representation is available from Haml.version.
|
107
|
+
# @api public
|
108
|
+
VERSION = version[:string] unless defined?(Haml::VERSION)
|
102
109
|
end
|
data/test/benchmark.rb
CHANGED
@@ -5,15 +5,14 @@ times = (ARGV.first || 1000).to_i
|
|
5
5
|
if times == 0 # Invalid parameter
|
6
6
|
puts <<END
|
7
7
|
ruby #$0 [times=1000]
|
8
|
-
Benchmark Haml against various other templating languages
|
9
|
-
on its own.
|
8
|
+
Benchmark Haml against various other templating languages.
|
10
9
|
END
|
11
10
|
exit 1
|
12
11
|
end
|
13
12
|
|
14
13
|
require File.dirname(__FILE__) + '/../lib/haml'
|
15
14
|
require File.dirname(__FILE__) + '/linked_rails'
|
16
|
-
%w[
|
15
|
+
%w[rubygems erb erubis markaby active_support action_controller
|
17
16
|
action_view action_pack haml/template rbench].each {|dep| require(dep)}
|
18
17
|
|
19
18
|
def view
|
@@ -91,9 +90,3 @@ RBench.run(times) do
|
|
91
90
|
haml_ugly { render @base, 'haml/templates/action_view_ugly' }
|
92
91
|
end
|
93
92
|
end
|
94
|
-
|
95
|
-
RBench.run(times) do
|
96
|
-
sass_template = File.read("#{File.dirname(__FILE__)}/sass/templates/complex.sass")
|
97
|
-
|
98
|
-
report("Sass") { Sass::Engine.new(sass_template).render }
|
99
|
-
end
|
data/test/haml/engine_test.rb
CHANGED
@@ -86,7 +86,6 @@ 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],
|
90
89
|
}
|
91
90
|
|
92
91
|
User = Struct.new('User', :id)
|
@@ -112,17 +111,6 @@ MESSAGE
|
|
112
111
|
Haml::Engine.new(text, options)
|
113
112
|
end
|
114
113
|
|
115
|
-
def setup
|
116
|
-
return if Haml::Util.ruby1_8?
|
117
|
-
@old_default_internal = Encoding.default_internal
|
118
|
-
Encoding.default_internal = nil
|
119
|
-
end
|
120
|
-
|
121
|
-
def teardown
|
122
|
-
return if Haml::Util.ruby1_8?
|
123
|
-
Encoding.default_internal = @old_default_internal
|
124
|
-
end
|
125
|
-
|
126
114
|
def test_empty_render
|
127
115
|
assert_equal "", render("")
|
128
116
|
end
|
@@ -775,38 +763,6 @@ HTML
|
|
775
763
|
HAML
|
776
764
|
end
|
777
765
|
|
778
|
-
def test_case_with_newline_after_case
|
779
|
-
assert_equal(<<HTML, render(<<HAML))
|
780
|
-
foo
|
781
|
-
HTML
|
782
|
-
- case 1
|
783
|
-
|
784
|
-
- when 1
|
785
|
-
foo
|
786
|
-
- when 2
|
787
|
-
bar
|
788
|
-
HAML
|
789
|
-
|
790
|
-
assert_equal(<<HTML, render(<<HAML))
|
791
|
-
bar
|
792
|
-
HTML
|
793
|
-
- case 2
|
794
|
-
|
795
|
-
- when 1
|
796
|
-
foo
|
797
|
-
- when 2
|
798
|
-
bar
|
799
|
-
HAML
|
800
|
-
end
|
801
|
-
|
802
|
-
def test_escape_html_with_interpolated_if_statement
|
803
|
-
assert_equal(<<HTML, render(<<HAML, :escape_html => true))
|
804
|
-
foo,
|
805
|
-
HTML
|
806
|
-
foo\#{"," if true}
|
807
|
-
HAML
|
808
|
-
end
|
809
|
-
|
810
766
|
# HTML escaping tests
|
811
767
|
|
812
768
|
def test_ampersand_equals_should_escape
|
@@ -1145,18 +1101,18 @@ END
|
|
1145
1101
|
end
|
1146
1102
|
|
1147
1103
|
def test_css_filter
|
1148
|
-
assert_equal(<<
|
1104
|
+
assert_equal(<<HTML, render(<<HAML))
|
1149
1105
|
<style type='text/css'>
|
1150
1106
|
/*<![CDATA[*/
|
1151
1107
|
#foo {
|
1152
1108
|
bar: baz; }
|
1153
1109
|
/*]]>*/
|
1154
1110
|
</style>
|
1155
|
-
|
1111
|
+
HTML
|
1156
1112
|
:css
|
1157
1113
|
#foo {
|
1158
1114
|
bar: baz; }
|
1159
|
-
|
1115
|
+
HAML
|
1160
1116
|
end
|
1161
1117
|
|
1162
1118
|
def test_local_assigns_dont_modify_class
|
@@ -1389,7 +1345,7 @@ SASS
|
|
1389
1345
|
|
1390
1346
|
def test_new_attribute_ids
|
1391
1347
|
assert_equal("<div id='foo_bar'></div>\n", render("#foo(id='bar')"))
|
1392
|
-
assert_equal("<div id='
|
1348
|
+
assert_equal("<div id='foo_bar_baz'></div>\n", render("#foo{:id => 'bar'}(id='baz')"))
|
1393
1349
|
assert_equal("<div id='foo_baz_bar'></div>\n", render("#foo(id='baz'){:id => 'bar'}"))
|
1394
1350
|
foo = User.new(42)
|
1395
1351
|
assert_equal("<div class='struct_user' id='foo_baz_bar_struct_user_42'></div>\n",
|
@@ -1398,7 +1354,7 @@ SASS
|
|
1398
1354
|
render("#foo(id='baz')[foo]{:id => 'bar'}", :locals => {:foo => foo}))
|
1399
1355
|
assert_equal("<div class='struct_user' id='foo_baz_bar_struct_user_42'></div>\n",
|
1400
1356
|
render("#foo[foo](id='baz'){:id => 'bar'}", :locals => {:foo => foo}))
|
1401
|
-
assert_equal("<div class='struct_user' id='
|
1357
|
+
assert_equal("<div class='struct_user' id='foo_bar_baz_struct_user_42'></div>\n",
|
1402
1358
|
render("#foo[foo]{:id => 'bar'}(id='baz')", :locals => {:foo => foo}))
|
1403
1359
|
end
|
1404
1360
|
|
@@ -1470,17 +1426,11 @@ SASS
|
|
1470
1426
|
assert_equal("<a a='b' c='d'>bar</a>\n", render("%a(c='d'){:a => 'b'} bar"))
|
1471
1427
|
assert_equal("<a a='b' c='d'>bar</a>\n", render("%a{:a => 'b'}(c='d') bar"))
|
1472
1428
|
|
1473
|
-
|
1474
|
-
# because theoretically old-style could have arbitrary end-of-method-call syntax.
|
1475
|
-
assert_equal("<a a='b'>bar</a>\n", render("%a{:a => 'b'}(a='d') bar"))
|
1429
|
+
assert_equal("<a a='d'>bar</a>\n", render("%a{:a => 'b'}(a='d') bar"))
|
1476
1430
|
assert_equal("<a a='b'>bar</a>\n", render("%a(a='d'){:a => 'b'} bar"))
|
1477
1431
|
|
1478
1432
|
assert_equal("<a a='b' b='c' c='d' d='e'>bar</a>\n",
|
1479
1433
|
render("%a{:a => 'b',\n:b => 'c'}(c='d'\nd='e') bar"))
|
1480
|
-
|
1481
|
-
locals = {:b => 'b', :d => 'd'}
|
1482
|
-
assert_equal("<p a='b' c='d'></p>\n", render("%p{:a => b}(c=d)", :locals => locals))
|
1483
|
-
assert_equal("<p a='b' c='d'></p>\n", render("%p(a=b){:c => d}", :locals => locals))
|
1484
1434
|
end
|
1485
1435
|
|
1486
1436
|
# Ruby Multiline
|
@@ -1556,7 +1506,7 @@ HAML
|
|
1556
1506
|
|
1557
1507
|
def test_loud_ruby_multiline_with_block
|
1558
1508
|
assert_equal(<<HTML, render(<<HAML))
|
1559
|
-
|
1509
|
+
farfazfang
|
1560
1510
|
<p>foo</p>
|
1561
1511
|
<p>bar</p>
|
1562
1512
|
HTML
|
@@ -1686,8 +1636,18 @@ HAML
|
|
1686
1636
|
HAML
|
1687
1637
|
end
|
1688
1638
|
|
1639
|
+
def test_convert_template_render
|
1640
|
+
assert_equal(<<HTML, render(<<HAML.encode("iso-8859-1"), :encoding => "utf-8"))
|
1641
|
+
<p>bâr</p>
|
1642
|
+
<p>föö</p>
|
1643
|
+
HTML
|
1644
|
+
%p bâr
|
1645
|
+
%p föö
|
1646
|
+
HAML
|
1647
|
+
end
|
1648
|
+
|
1689
1649
|
def test_fake_ascii_encoding
|
1690
|
-
|
1650
|
+
assert_equal(<<HTML.force_encoding("ascii-8bit"), render(<<HAML, :encoding => "ascii-8bit"))
|
1691
1651
|
<p>bâr</p>
|
1692
1652
|
<p>föö</p>
|
1693
1653
|
HTML
|
@@ -1741,23 +1701,15 @@ HTML
|
|
1741
1701
|
HAML
|
1742
1702
|
end
|
1743
1703
|
|
1744
|
-
def
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
assert_valid_encoding_comment("-# -*- coding: ibm866 -*-")
|
1754
|
-
assert_valid_encoding_comment("-# -*- encoding: ibm866 -*-")
|
1755
|
-
assert_valid_encoding_comment('-# -*- coding: "ibm866" -*-')
|
1756
|
-
assert_valid_encoding_comment("-#-*-coding:ibm866-*-")
|
1757
|
-
assert_valid_encoding_comment("-#-*-coding:ibm866-*-")
|
1758
|
-
assert_valid_encoding_comment("-# -*- foo: bar; coding: ibm866; baz: bang -*-")
|
1759
|
-
assert_valid_encoding_comment("-# foo bar coding: baz -*- coding: ibm866 -*-")
|
1760
|
-
assert_valid_encoding_comment("-# -*- coding: ibm866 -*- foo bar coding: baz")
|
1704
|
+
def test_different_coding_comment_than_encoding
|
1705
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1706
|
+
<p>bâr</p>
|
1707
|
+
<p>föö</p>
|
1708
|
+
HTML
|
1709
|
+
-# coding: ibm866
|
1710
|
+
%p bâr
|
1711
|
+
%p föö
|
1712
|
+
HAML
|
1761
1713
|
end
|
1762
1714
|
|
1763
1715
|
def test_different_coding_than_system
|
@@ -1767,27 +1719,182 @@ HTML
|
|
1767
1719
|
%p тАЬ
|
1768
1720
|
HAML
|
1769
1721
|
end
|
1770
|
-
end
|
1771
1722
|
|
1772
|
-
|
1723
|
+
def test_case_insensitive_coding_comment
|
1724
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1725
|
+
<p>bâr</p>
|
1726
|
+
<p>föö</p>
|
1727
|
+
HTML
|
1728
|
+
-# CodINg: IbM866
|
1729
|
+
%p bâr
|
1730
|
+
%p föö
|
1731
|
+
HAML
|
1732
|
+
end
|
1773
1733
|
|
1774
|
-
|
1775
|
-
|
1776
|
-
<p
|
1777
|
-
<p
|
1734
|
+
def test_whitespace_insensitive_coding_comment
|
1735
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1736
|
+
<p>bâr</p>
|
1737
|
+
<p>föö</p>
|
1778
1738
|
HTML
|
1779
|
-
|
1780
|
-
%p
|
1781
|
-
%p
|
1739
|
+
-#coding:ibm866
|
1740
|
+
%p bâr
|
1741
|
+
%p föö
|
1742
|
+
HAML
|
1743
|
+
end
|
1744
|
+
|
1745
|
+
def test_equals_coding_comment
|
1746
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1747
|
+
<p>bâr</p>
|
1748
|
+
<p>föö</p>
|
1749
|
+
HTML
|
1750
|
+
-# CodINg= ibm866
|
1751
|
+
%p bâr
|
1752
|
+
%p föö
|
1753
|
+
HAML
|
1754
|
+
end
|
1755
|
+
|
1756
|
+
def test_prefixed_coding_comment
|
1757
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1758
|
+
<p>bâr</p>
|
1759
|
+
<p>föö</p>
|
1760
|
+
HTML
|
1761
|
+
-# foo BAR FAOJcoding: ibm866
|
1762
|
+
%p bâr
|
1763
|
+
%p föö
|
1764
|
+
HAML
|
1765
|
+
end
|
1766
|
+
|
1767
|
+
def test_suffixed_coding_comment
|
1768
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1769
|
+
<p>bâr</p>
|
1770
|
+
<p>föö</p>
|
1771
|
+
HTML
|
1772
|
+
-# coding: ibm866 ASFJ (&(&#!$
|
1773
|
+
%p bâr
|
1774
|
+
%p föö
|
1782
1775
|
HAML
|
1776
|
+
end
|
1777
|
+
|
1778
|
+
def test_emacs_prefixed_coding_comment
|
1779
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1780
|
+
<p>bâr</p>
|
1781
|
+
<p>föö</p>
|
1782
|
+
HTML
|
1783
|
+
-# -*- coding: ibm866
|
1784
|
+
%p bâr
|
1785
|
+
%p föö
|
1786
|
+
HAML
|
1787
|
+
end
|
1788
|
+
|
1789
|
+
def test_emacs_suffixed_coding_comment
|
1790
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1791
|
+
<p>bâr</p>
|
1792
|
+
<p>föö</p>
|
1793
|
+
HTML
|
1794
|
+
-# coding: ibm866 -*- coding: blah
|
1795
|
+
%p bâr
|
1796
|
+
%p föö
|
1797
|
+
HAML
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
def test_emacs_coding_comment
|
1801
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1802
|
+
<p>bâr</p>
|
1803
|
+
<p>föö</p>
|
1804
|
+
HTML
|
1805
|
+
-# -*- coding: ibm866 -*-
|
1806
|
+
%p bâr
|
1807
|
+
%p föö
|
1808
|
+
HAML
|
1809
|
+
end
|
1810
|
+
|
1811
|
+
def test_emacs_encoding_comment
|
1812
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1813
|
+
<p>bâr</p>
|
1814
|
+
<p>föö</p>
|
1815
|
+
HTML
|
1816
|
+
-# -*- encoding: ibm866 -*-
|
1817
|
+
%p bâr
|
1818
|
+
%p föö
|
1819
|
+
HAML
|
1820
|
+
end
|
1821
|
+
|
1822
|
+
def test_quoted_emacs_coding_comment
|
1823
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1824
|
+
<p>bâr</p>
|
1825
|
+
<p>föö</p>
|
1826
|
+
HTML
|
1827
|
+
-# -*- coding: "ibm866" -*-
|
1828
|
+
%p bâr
|
1829
|
+
%p föö
|
1830
|
+
HAML
|
1831
|
+
end
|
1832
|
+
|
1833
|
+
def test_whitespace_insensitive_emacs_coding_comment
|
1834
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1835
|
+
<p>bâr</p>
|
1836
|
+
<p>föö</p>
|
1837
|
+
HTML
|
1838
|
+
-#-*-coding:ibm866-*-
|
1839
|
+
%p bâr
|
1840
|
+
%p föö
|
1841
|
+
HAML
|
1842
|
+
end
|
1843
|
+
|
1844
|
+
def test_whitespace_insensitive_emacs_coding_comment
|
1845
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1846
|
+
<p>bâr</p>
|
1847
|
+
<p>föö</p>
|
1848
|
+
HTML
|
1849
|
+
-#-*-coding:ibm866-*-
|
1850
|
+
%p bâr
|
1851
|
+
%p föö
|
1852
|
+
HAML
|
1853
|
+
end
|
1854
|
+
|
1855
|
+
def test_one_of_several_emacs_comments
|
1856
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1857
|
+
<p>bâr</p>
|
1858
|
+
<p>föö</p>
|
1859
|
+
HTML
|
1860
|
+
-# -*- foo: bar; coding: ibm866; baz: bang -*-
|
1861
|
+
%p bâr
|
1862
|
+
%p föö
|
1863
|
+
HAML
|
1864
|
+
end
|
1865
|
+
|
1866
|
+
def test_prefixed_emacs_coding_comment
|
1867
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1868
|
+
<p>bâr</p>
|
1869
|
+
<p>föö</p>
|
1870
|
+
HTML
|
1871
|
+
-# foo bar coding: baz -*- coding: ibm866 -*-
|
1872
|
+
%p bâr
|
1873
|
+
%p föö
|
1874
|
+
HAML
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
def test_suffixed_emacs_coding_comment
|
1878
|
+
assert_renders_encoded(<<HTML.force_encoding("IBM866"), <<HAML)
|
1879
|
+
<p>bâr</p>
|
1880
|
+
<p>föö</p>
|
1881
|
+
HTML
|
1882
|
+
-# -*- coding: ibm866 -*- foo bar coding: baz
|
1883
|
+
%p bâr
|
1884
|
+
%p föö
|
1885
|
+
HAML
|
1886
|
+
end
|
1887
|
+
|
1783
1888
|
end
|
1784
1889
|
|
1890
|
+
private
|
1891
|
+
|
1785
1892
|
def assert_converts_template_properly
|
1786
|
-
engine = Haml::Engine.new(<<HAML.encode("iso-8859-1"), :encoding => "
|
1893
|
+
engine = Haml::Engine.new(<<HAML.encode("iso-8859-1"), :encoding => "utf-8")
|
1787
1894
|
%p bâr
|
1788
1895
|
%p föö
|
1789
1896
|
HAML
|
1790
|
-
|
1897
|
+
assert_equal(<<HTML, yield(engine))
|
1791
1898
|
<p>bâr</p>
|
1792
1899
|
<p>föö</p>
|
1793
1900
|
HTML
|
@@ -1795,11 +1902,7 @@ HTML
|
|
1795
1902
|
|
1796
1903
|
def assert_renders_encoded(html, haml)
|
1797
1904
|
result = render(haml)
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
def assert_encoded_equal(expected, actual)
|
1802
|
-
assert_equal expected.encoding, actual.encoding
|
1803
|
-
assert_equal expected, actual
|
1905
|
+
assert_equal html.encoding, result.encoding
|
1906
|
+
assert_equal html, result
|
1804
1907
|
end
|
1805
1908
|
end
|
@@ -421,20 +421,6 @@ HAML
|
|
421
421
|
<tr></tr>
|
422
422
|
<% end %>
|
423
423
|
</table>
|
424
|
-
ERB
|
425
|
-
end
|
426
|
-
|
427
|
-
def test_silent_inside_block_inside_tag
|
428
|
-
assert_equal(<<HAML.rstrip, render_erb(<<ERB))
|
429
|
-
%table
|
430
|
-
- foo.each do
|
431
|
-
- haml_puts "foo"
|
432
|
-
HAML
|
433
|
-
<table>
|
434
|
-
<% foo.each do %>
|
435
|
-
<% haml_puts "foo" %>
|
436
|
-
<% end %>
|
437
|
-
</table>
|
438
424
|
ERB
|
439
425
|
end
|
440
426
|
end
|
data/test/haml/util_test.rb
CHANGED
@@ -5,6 +5,19 @@ require 'pathname'
|
|
5
5
|
class UtilTest < Test::Unit::TestCase
|
6
6
|
include Haml::Util
|
7
7
|
|
8
|
+
class Dumpable
|
9
|
+
attr_reader :arr
|
10
|
+
def initialize; @arr = []; end
|
11
|
+
def _before_dump; @arr << :before; end
|
12
|
+
def _after_dump; @arr << :after; end
|
13
|
+
def _around_dump
|
14
|
+
@arr << :around_before
|
15
|
+
yield
|
16
|
+
@arr << :around_after
|
17
|
+
end
|
18
|
+
def _after_load; @arr << :loaded; end
|
19
|
+
end
|
20
|
+
|
8
21
|
def test_scope
|
9
22
|
assert(File.exist?(scope("Rakefile")))
|
10
23
|
end
|
@@ -240,6 +253,25 @@ class UtilTest < Test::Unit::TestCase
|
|
240
253
|
assert(!version_gt(v2, v1), "Expected #{v2} = #{v1}")
|
241
254
|
end
|
242
255
|
|
256
|
+
def test_dump_and_load
|
257
|
+
obj = Dumpable.new
|
258
|
+
data = dump(obj)
|
259
|
+
assert_equal([:before, :around_before, :around_after, :after], obj.arr)
|
260
|
+
obj2 = load(data)
|
261
|
+
assert_equal([:before, :around_before, :loaded], obj2.arr)
|
262
|
+
end
|
263
|
+
|
264
|
+
class FooBar
|
265
|
+
def foo
|
266
|
+
Haml::Util.abstract(self)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_abstract
|
271
|
+
assert_raise_message(NotImplementedError,
|
272
|
+
"UtilTest::FooBar must implement #foo") {FooBar.new.foo}
|
273
|
+
end
|
274
|
+
|
243
275
|
def test_def_static_method
|
244
276
|
klass = Class.new
|
245
277
|
def_static_method(klass, :static_method, [:arg1, :arg2],
|