super-pro-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/slim-5.2.1/CHANGES +496 -0
- data/slim-5.2.1/Gemfile +43 -0
- data/slim-5.2.1/LICENSE +21 -0
- data/slim-5.2.1/README.jp.md +1276 -0
- data/slim-5.2.1/README.md +1313 -0
- data/slim-5.2.1/Rakefile +80 -0
- data/slim-5.2.1/bin/slimrb +6 -0
- data/slim-5.2.1/doc/include.md +20 -0
- data/slim-5.2.1/doc/jp/include.md +20 -0
- data/slim-5.2.1/doc/jp/logic_less.md +137 -0
- data/slim-5.2.1/doc/jp/smart.md +102 -0
- data/slim-5.2.1/doc/jp/translator.md +28 -0
- data/slim-5.2.1/doc/logic_less.md +137 -0
- data/slim-5.2.1/doc/smart.md +120 -0
- data/slim-5.2.1/doc/translator.md +28 -0
- data/slim-5.2.1/lib/slim/code_attributes.rb +68 -0
- data/slim-5.2.1/lib/slim/command.rb +122 -0
- data/slim-5.2.1/lib/slim/controls.rb +61 -0
- data/slim-5.2.1/lib/slim/do_inserter.rb +34 -0
- data/slim-5.2.1/lib/slim/embedded.rb +248 -0
- data/slim-5.2.1/lib/slim/end_inserter.rb +63 -0
- data/slim-5.2.1/lib/slim/engine.rb +42 -0
- data/slim-5.2.1/lib/slim/erb_converter.rb +15 -0
- data/slim-5.2.1/lib/slim/filter.rb +31 -0
- data/slim-5.2.1/lib/slim/grammar.rb +24 -0
- data/slim-5.2.1/lib/slim/include.rb +58 -0
- data/slim-5.2.1/lib/slim/interpolation.rb +36 -0
- data/slim-5.2.1/lib/slim/logic_less/context.rb +126 -0
- data/slim-5.2.1/lib/slim/logic_less/filter.rb +81 -0
- data/slim-5.2.1/lib/slim/logic_less.rb +6 -0
- data/slim-5.2.1/lib/slim/parser.rb +535 -0
- data/slim-5.2.1/lib/slim/railtie.rb +19 -0
- data/slim-5.2.1/lib/slim/smart/escaper.rb +42 -0
- data/slim-5.2.1/lib/slim/smart/filter.rb +97 -0
- data/slim-5.2.1/lib/slim/smart/parser.rb +35 -0
- data/slim-5.2.1/lib/slim/smart.rb +9 -0
- data/slim-5.2.1/lib/slim/splat/builder.rb +115 -0
- data/slim-5.2.1/lib/slim/splat/filter.rb +93 -0
- data/slim-5.2.1/lib/slim/template.rb +6 -0
- data/slim-5.2.1/lib/slim/translator.rb +119 -0
- data/slim-5.2.1/lib/slim/version.rb +6 -0
- data/slim-5.2.1/lib/slim.rb +16 -0
- data/slim-5.2.1/slim.gemspec +33 -0
- data/slim-5.2.1/test/core/helper.rb +201 -0
- data/slim-5.2.1/test/core/test_code_blocks.rb +194 -0
- data/slim-5.2.1/test/core/test_code_escaping.rb +162 -0
- data/slim-5.2.1/test/core/test_code_evaluation.rb +181 -0
- data/slim-5.2.1/test/core/test_code_output.rb +168 -0
- data/slim-5.2.1/test/core/test_code_structure.rb +203 -0
- data/slim-5.2.1/test/core/test_commands.rb +219 -0
- data/slim-5.2.1/test/core/test_embedded_engines.rb +247 -0
- data/slim-5.2.1/test/core/test_encoding.rb +28 -0
- data/slim-5.2.1/test/core/test_erb_converter.rb +65 -0
- data/slim-5.2.1/test/core/test_html_attributes.rb +276 -0
- data/slim-5.2.1/test/core/test_html_escaping.rb +65 -0
- data/slim-5.2.1/test/core/test_html_structure.rb +599 -0
- data/slim-5.2.1/test/core/test_parser_errors.rb +148 -0
- data/slim-5.2.1/test/core/test_pretty.rb +163 -0
- data/slim-5.2.1/test/core/test_ruby_errors.rb +200 -0
- data/slim-5.2.1/test/core/test_slim_template.rb +78 -0
- data/slim-5.2.1/test/core/test_splat_prefix_option.rb +155 -0
- data/slim-5.2.1/test/core/test_tabs.rb +169 -0
- data/slim-5.2.1/test/core/test_text_interpolation.rb +79 -0
- data/slim-5.2.1/test/core/test_thread_options.rb +18 -0
- data/slim-5.2.1/test/core/test_unicode.rb +15 -0
- data/slim-5.2.1/test/include/files/recursive.slim +1 -0
- data/slim-5.2.1/test/include/files/slimfile.slim +3 -0
- data/slim-5.2.1/test/include/files/subdir/test.slim +1 -0
- data/slim-5.2.1/test/include/files/textfile +1 -0
- data/slim-5.2.1/test/include/test_include.rb +24 -0
- data/slim-5.2.1/test/literate/TESTS.md +1323 -0
- data/slim-5.2.1/test/literate/helper.rb +15 -0
- data/slim-5.2.1/test/literate/run.rb +92 -0
- data/slim-5.2.1/test/logic_less/test_logic_less.rb +330 -0
- data/slim-5.2.1/test/rails/Rakefile +7 -0
- data/slim-5.2.1/test/rails/app/assets/config/manifest.js +1 -0
- data/slim-5.2.1/test/rails/app/controllers/application_controller.rb +2 -0
- data/slim-5.2.1/test/rails/app/controllers/entries_controller.rb +5 -0
- data/slim-5.2.1/test/rails/app/controllers/slim_controller.rb +46 -0
- data/slim-5.2.1/test/rails/app/helpers/application_helper.rb +5 -0
- data/slim-5.2.1/test/rails/app/models/entry.rb +16 -0
- data/slim-5.2.1/test/rails/app/views/entries/edit.html.slim +3 -0
- data/slim-5.2.1/test/rails/app/views/layouts/application.html+testvariant.slim +10 -0
- data/slim-5.2.1/test/rails/app/views/layouts/application.html.slim +10 -0
- data/slim-5.2.1/test/rails/app/views/slim/_partial.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/attributes.html.slim +3 -0
- data/slim-5.2.1/test/rails/app/views/slim/content_for.html.slim +7 -0
- data/slim-5.2.1/test/rails/app/views/slim/erb.html.erb +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/form_for.html.slim +2 -0
- data/slim-5.2.1/test/rails/app/views/slim/helper.html.slim +4 -0
- data/slim-5.2.1/test/rails/app/views/slim/integers.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/no_layout.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/normal.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/partial.html.slim +2 -0
- data/slim-5.2.1/test/rails/app/views/slim/splat.html.slim +2 -0
- data/slim-5.2.1/test/rails/app/views/slim/splat_with_delimiter.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/thread_options.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/variables.html.slim +1 -0
- data/slim-5.2.1/test/rails/app/views/slim/xml.slim +1 -0
- data/slim-5.2.1/test/rails/config/application.rb +44 -0
- data/slim-5.2.1/test/rails/config/boot.rb +10 -0
- data/slim-5.2.1/test/rails/config/environment.rb +5 -0
- data/slim-5.2.1/test/rails/config/environments/test.rb +34 -0
- data/slim-5.2.1/test/rails/config/initializers/backtrace_silencers.rb +7 -0
- data/slim-5.2.1/test/rails/config/initializers/inflections.rb +10 -0
- data/slim-5.2.1/test/rails/config/initializers/mime_types.rb +5 -0
- data/slim-5.2.1/test/rails/config/initializers/session_store.rb +8 -0
- data/slim-5.2.1/test/rails/config/locales/en.yml +5 -0
- data/slim-5.2.1/test/rails/config/routes.rb +60 -0
- data/slim-5.2.1/test/rails/config.ru +4 -0
- data/slim-5.2.1/test/rails/script/rails +6 -0
- data/slim-5.2.1/test/rails/test/helper.rb +34 -0
- data/slim-5.2.1/test/rails/test/test_slim.rb +102 -0
- data/slim-5.2.1/test/sinatra/contest.rb +91 -0
- data/slim-5.2.1/test/sinatra/helper.rb +143 -0
- data/slim-5.2.1/test/sinatra/test_core.rb +91 -0
- data/slim-5.2.1/test/sinatra/test_include.rb +16 -0
- data/slim-5.2.1/test/sinatra/views/embed_include_js.slim +8 -0
- data/slim-5.2.1/test/sinatra/views/embed_js.slim +11 -0
- data/slim-5.2.1/test/sinatra/views/footer.slim +1 -0
- data/slim-5.2.1/test/sinatra/views/hello.slim +1 -0
- data/slim-5.2.1/test/sinatra/views/layout2.slim +3 -0
- data/slim-5.2.1/test/smart/test_smart_text.rb +294 -0
- data/slim-5.2.1/test/translator/test_translator.rb +76 -0
- data/super-pro-kit.gemspec +11 -0
- metadata +165 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
require 'slim/erb_converter'
|
|
3
|
+
|
|
4
|
+
class TestSlimERBConverter < TestSlim
|
|
5
|
+
def test_converter
|
|
6
|
+
source = %q{
|
|
7
|
+
doctype 5
|
|
8
|
+
html
|
|
9
|
+
head
|
|
10
|
+
title Hello World!
|
|
11
|
+
/! Meta tags
|
|
12
|
+
with long explanatory
|
|
13
|
+
multiline comment
|
|
14
|
+
meta name="description" content="template language"
|
|
15
|
+
/! Stylesheets
|
|
16
|
+
link href="style.css" media="screen" rel="stylesheet" type="text/css"
|
|
17
|
+
link href="colors.css" media="screen" rel="stylesheet" type="text/css"
|
|
18
|
+
/! Javascripts
|
|
19
|
+
script src="jquery.js"
|
|
20
|
+
script src="jquery.ui.js"
|
|
21
|
+
/[if lt IE 9]
|
|
22
|
+
script src="old-ie1.js"
|
|
23
|
+
script src="old-ie2.js"
|
|
24
|
+
css:
|
|
25
|
+
body { background-color: red; }
|
|
26
|
+
body
|
|
27
|
+
#container
|
|
28
|
+
p Hello
|
|
29
|
+
World!
|
|
30
|
+
p= "dynamic text with\nnewline"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
result = %q{
|
|
34
|
+
<!DOCTYPE html>
|
|
35
|
+
<html>
|
|
36
|
+
<head>
|
|
37
|
+
<title>Hello World!</title>
|
|
38
|
+
<!--Meta tags
|
|
39
|
+
|
|
40
|
+
with long explanatory
|
|
41
|
+
|
|
42
|
+
multiline comment-->
|
|
43
|
+
<meta content="template language" name="description" />
|
|
44
|
+
<!--Stylesheets-->
|
|
45
|
+
<link href="style.css" media="screen" rel="stylesheet" type="text/css" />
|
|
46
|
+
<link href="colors.css" media="screen" rel="stylesheet" type="text/css" />
|
|
47
|
+
<!--Javascripts-->
|
|
48
|
+
<script src="jquery.js">
|
|
49
|
+
</script><script src="jquery.ui.js">
|
|
50
|
+
</script><!--[if lt IE 9]>
|
|
51
|
+
<script src="old-ie1.js">
|
|
52
|
+
</script><script src="old-ie2.js">
|
|
53
|
+
</script><![endif]--><style>
|
|
54
|
+
body { background-color: red; }</style>
|
|
55
|
+
</head><body>
|
|
56
|
+
<div id="container">
|
|
57
|
+
<p>Hello
|
|
58
|
+
|
|
59
|
+
World!</p>
|
|
60
|
+
<p><%= ::Temple::Utils.escape_html(("dynamic text with\nnewline")) %>
|
|
61
|
+
</p></div></body></html>}
|
|
62
|
+
|
|
63
|
+
assert_equal result, Slim::ERBConverter.new.call(source)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestSlimHTMLAttributes < TestSlim
|
|
4
|
+
def test_ternary_operation_in_attribute
|
|
5
|
+
source = %q{
|
|
6
|
+
p id="#{(false ? 'notshown' : 'shown')}" = output_number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
assert_html '<p id="shown">1337</p>', source
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_ternary_operation_in_attribute_2
|
|
13
|
+
source = %q{
|
|
14
|
+
p id=(false ? 'notshown' : 'shown') = output_number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
assert_html '<p id="shown">1337</p>', source
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_class_attribute_merging
|
|
21
|
+
source = %{
|
|
22
|
+
.alpha class="beta" Test it
|
|
23
|
+
}
|
|
24
|
+
assert_html '<div class="alpha beta">Test it</div>', source
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_class_attribute_merging_with_nil
|
|
28
|
+
source = %{
|
|
29
|
+
.alpha class="beta" class=nil class="gamma" Test it
|
|
30
|
+
}
|
|
31
|
+
assert_html '<div class="alpha beta gamma">Test it</div>', source
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_class_attribute_merging_with_empty_static
|
|
35
|
+
source = %{
|
|
36
|
+
.alpha class="beta" class="" class="gamma" Test it
|
|
37
|
+
}
|
|
38
|
+
assert_html '<div class="alpha beta gamma">Test it</div>', source
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_id_attribute_merging
|
|
42
|
+
source = %{
|
|
43
|
+
#alpha id="beta" Test it
|
|
44
|
+
}
|
|
45
|
+
assert_html '<div id="alpha_beta">Test it</div>', source, merge_attrs: {'class' => ' ', 'id' => '_' }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_id_attribute_merging2
|
|
49
|
+
source = %{
|
|
50
|
+
#alpha id="beta" Test it
|
|
51
|
+
}
|
|
52
|
+
assert_html '<div id="alpha-beta">Test it</div>', source, merge_attrs: {'class' => ' ', 'id' => '-' }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_boolean_attribute_false
|
|
56
|
+
source = %{
|
|
57
|
+
- cond=false
|
|
58
|
+
option selected=false Text
|
|
59
|
+
option selected=cond Text2
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
assert_html '<option>Text</option><option>Text2</option>', source
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_boolean_attribute_true
|
|
66
|
+
source = %{
|
|
67
|
+
- cond=true
|
|
68
|
+
option selected=true Text
|
|
69
|
+
option selected=cond Text2
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
assert_html '<option selected="">Text</option><option selected="">Text2</option>', source
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_boolean_attribute_nil
|
|
76
|
+
source = %{
|
|
77
|
+
- cond=nil
|
|
78
|
+
option selected=nil Text
|
|
79
|
+
option selected=cond Text2
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
assert_html '<option>Text</option><option>Text2</option>', source
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_boolean_attribute_string2
|
|
86
|
+
source = %{
|
|
87
|
+
option selected="selected" Text
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assert_html '<option selected="selected">Text</option>', source
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_boolean_attribute_shortcut
|
|
94
|
+
source = %{
|
|
95
|
+
option(class="clazz" selected) Text
|
|
96
|
+
option(selected class="clazz") Text
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
assert_html '<option class="clazz" selected="">Text</option><option class="clazz" selected="">Text</option>', source
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_array_attribute_merging
|
|
103
|
+
source = %{
|
|
104
|
+
.alpha class="beta" class=[[""], :gamma, nil, :delta, [true, false]]
|
|
105
|
+
.alpha class=:beta,:gamma
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
assert_html '<div class="alpha beta gamma delta true false"></div><div class="alpha beta gamma"></div>', source
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_hyphenated_attribute
|
|
112
|
+
source = %{
|
|
113
|
+
.alpha data={a: 'alpha', b: 'beta', c_d: 'gamma', c: {e: 'epsilon'}}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
assert_html '<div class="alpha" data-a="alpha" data-b="beta" data-c-e="epsilon" data-c_d="gamma"></div>', source
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_hyphenated_underscore_attribute
|
|
120
|
+
source = %{
|
|
121
|
+
.alpha data={a: 'alpha', b: 'beta', c_d: 'gamma', c: {e: 'epsilon'}}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
assert_html '<div class="alpha" data-a="alpha" data-b="beta" data-c-d="gamma" data-c-e="epsilon"></div>', source, hyphen_underscore_attrs: true
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_splat_without_content
|
|
128
|
+
source = %q{
|
|
129
|
+
*hash
|
|
130
|
+
p*hash
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
assert_html '<div a="The letter a" b="The letter b"></div><p a="The letter a" b="The letter b"></p>', source
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_shortcut_splat
|
|
137
|
+
source = %q{
|
|
138
|
+
*hash This is my title
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
assert_html '<div a="The letter a" b="The letter b">This is my title</div>', source
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_splat
|
|
145
|
+
source = %q{
|
|
146
|
+
h1 *hash class=[] This is my title
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
assert_html '<h1 a="The letter a" b="The letter b">This is my title</h1>', source
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_closed_splat
|
|
153
|
+
source = %q{
|
|
154
|
+
*hash /
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
assert_html '<div a="The letter a" b="The letter b" />', source
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_splat_tag_name
|
|
161
|
+
source = %q{
|
|
162
|
+
*{tag: 'h1', id: 'title'} This is my title
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
assert_html '<h1 id="title">This is my title</h1>', source
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_splat_empty_tag_name
|
|
170
|
+
source = %q{
|
|
171
|
+
*{tag: '', id: 'test'} This is my title
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
assert_html '<div id="test">This is my title</div>', source
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_closed_splat_tag
|
|
178
|
+
source = %q{
|
|
179
|
+
*hash /
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
assert_html '<div a="The letter a" b="The letter b" />', source
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_splat_with_id_shortcut
|
|
186
|
+
source = %q{
|
|
187
|
+
#myid*hash This is my title
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
assert_html '<div a="The letter a" b="The letter b" id="myid">This is my title</div>', source
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def test_splat_with_class_shortcut
|
|
194
|
+
source = %q{
|
|
195
|
+
.myclass*hash This is my title
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
assert_html '<div a="The letter a" b="The letter b" class="myclass">This is my title</div>', source
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def test_splat_with_id_and_class_shortcuts
|
|
202
|
+
source = %q{
|
|
203
|
+
#myid.myclass*hash This is my title
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
assert_html '<div a="The letter a" b="The letter b" class="myclass" id="myid">This is my title</div>', source
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def test_splat_with_class_merging
|
|
210
|
+
source = %q{
|
|
211
|
+
#myid.myclass *{class: [:secondclass, %w(x y z)]} *hash This is my title
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
assert_html '<div a="The letter a" b="The letter b" class="myclass secondclass x y z" id="myid">This is my title</div>', source
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def test_splat_with_boolean_attribute
|
|
218
|
+
source = %q{
|
|
219
|
+
*{disabled: true, empty1: false, nonempty: '', empty2: nil} This is my title
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
assert_html '<div disabled="" nonempty="">This is my title</div>', source
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def test_splat_merging_with_arrays
|
|
226
|
+
source = %q{
|
|
227
|
+
*{a: 1, b: 2} *[[:c, 3], [:d, 4]] *[[:e, 5], [:f, 6]] This is my title
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
assert_html '<div a="1" b="2" c="3" d="4" e="5" f="6">This is my title</div>', source
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def test_splat_with_other_attributes
|
|
234
|
+
source = %q{
|
|
235
|
+
h1 data-id="123" *hash This is my title
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
assert_html '<h1 a="The letter a" b="The letter b" data-id="123">This is my title</h1>', source
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def test_attribute_merging
|
|
242
|
+
source = %q{
|
|
243
|
+
a class=true class=false
|
|
244
|
+
a class=false *{class:true}
|
|
245
|
+
a class=true
|
|
246
|
+
a class=false
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
assert_html '<a class="true false"></a><a class="false true"></a><a class="true"></a><a class="false"></a>', source
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def test_static_empty_attribute
|
|
253
|
+
source = %q{
|
|
254
|
+
p(id="marvin" name="" class="" data-info="Illudium Q-36")= output_number
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
assert_html '<p data-info="Illudium Q-36" id="marvin" name="">1337</p>', source
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def test_dynamic_empty_attribute
|
|
261
|
+
source = %q{
|
|
262
|
+
p(id="marvin" class=nil nonempty=("".to_s) data-info="Illudium Q-36")= output_number
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
assert_html '<p data-info="Illudium Q-36" id="marvin" nonempty="">1337</p>', source
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def test_weird_attribute
|
|
269
|
+
source = %q{
|
|
270
|
+
p
|
|
271
|
+
img(src='img.png' whatsthis?!)
|
|
272
|
+
img src='img.png' whatsthis?!="wtf"
|
|
273
|
+
}
|
|
274
|
+
assert_html '<p><img src="img.png" whatsthis?!="" /><img src="img.png" whatsthis?!="wtf" /></p>', source
|
|
275
|
+
end
|
|
276
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestSlimHtmlEscaping < TestSlim
|
|
4
|
+
def test_html_will_not_be_escaped
|
|
5
|
+
source = %q{
|
|
6
|
+
p <Hello> World, meet "Slim".
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
assert_html '<p><Hello> World, meet "Slim".</p>', source
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_html_with_newline_will_not_be_escaped
|
|
13
|
+
source = %q{
|
|
14
|
+
p
|
|
15
|
+
|
|
|
16
|
+
<Hello> World,
|
|
17
|
+
meet "Slim".
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
assert_html "<p><Hello> World,\n meet \"Slim\".</p>", source
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_html_with_escaped_interpolation
|
|
24
|
+
source = %q{
|
|
25
|
+
- x = '"'
|
|
26
|
+
- content = '<x>'
|
|
27
|
+
p class="#{x}" test #{content}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
assert_html '<p class=""">test <x></p>', source
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_html_nested_escaping
|
|
34
|
+
source = %q{
|
|
35
|
+
= hello_world do
|
|
36
|
+
| escaped &
|
|
37
|
+
}
|
|
38
|
+
assert_html 'Hello World from @env escaped & Hello World from @env', source
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_html_quoted_attr_escape
|
|
42
|
+
source = %q{
|
|
43
|
+
p id="&" class=="&"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
assert_html '<p class="&" id="&"></p>', source
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_html_quoted_attr_escape_with_interpolation
|
|
50
|
+
source = %q{
|
|
51
|
+
p id="&#{'"'}" class=="&#{'"'}"
|
|
52
|
+
p id="&#{{'"'}}" class=="&#{{'"'}}"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
assert_html '<p class="&"" id="&""></p><p class="&"" id="&""></p>', source
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_html_ruby_attr_escape
|
|
59
|
+
source = %q{
|
|
60
|
+
p id=('&'.to_s) class==('&'.to_s)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
assert_html '<p class="&" id="&"></p>', source
|
|
64
|
+
end
|
|
65
|
+
end
|