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,599 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestSlimHtmlStructure < TestSlim
|
|
4
|
+
def test_simple_render
|
|
5
|
+
# Keep the trailing space behind "body "!
|
|
6
|
+
source = %q{
|
|
7
|
+
html
|
|
8
|
+
head
|
|
9
|
+
title Simple Test Title
|
|
10
|
+
body
|
|
11
|
+
p Hello World, meet Slim.
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
assert_html '<html><head><title>Simple Test Title</title></head><body><p>Hello World, meet Slim.</p></body></html>', source
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_relaxed_indentation_of_first_line
|
|
18
|
+
source = %q{
|
|
19
|
+
p
|
|
20
|
+
.content
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
assert_html "<p><div class=\"content\"></div></p>", source
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_html_tag_with_text_and_empty_line
|
|
27
|
+
source = %q{
|
|
28
|
+
p Hello
|
|
29
|
+
|
|
30
|
+
p World
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
assert_html "<p>Hello</p><p>World</p>", source
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_html_namespaces
|
|
37
|
+
source = %q{
|
|
38
|
+
html:body
|
|
39
|
+
html:p html:id="test" Text
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
assert_html '<html:body><html:p html:id="test">Text</html:p></html:body>', source
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_doctype
|
|
46
|
+
source = %q{
|
|
47
|
+
doctype 1.1
|
|
48
|
+
html
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
assert_html '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html></html>', source, format: :xhtml
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_doctype_new_syntax
|
|
55
|
+
source = %q{
|
|
56
|
+
doctype 5
|
|
57
|
+
html
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
assert_html '<!DOCTYPE html><html></html>', source, format: :xhtml
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_doctype_new_syntax_html5
|
|
64
|
+
source = %q{
|
|
65
|
+
doctype html
|
|
66
|
+
html
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
assert_html '<!DOCTYPE html><html></html>', source, format: :xhtml
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_render_with_shortcut_attributes
|
|
73
|
+
source = %q{
|
|
74
|
+
h1#title This is my title
|
|
75
|
+
#notice.hello.world
|
|
76
|
+
= hello_world
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
assert_html '<h1 id="title">This is my title</h1><div class="hello world" id="notice">Hello World from @env</div>', source
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_render_with_overwritten_default_tag
|
|
83
|
+
source = %q{
|
|
84
|
+
#notice.hello.world
|
|
85
|
+
= hello_world
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
assert_html '<section class="hello world" id="notice">Hello World from @env</section>', source, default_tag: 'section'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_render_with_custom_shortcut
|
|
92
|
+
source = %q{
|
|
93
|
+
#notice.hello.world@test
|
|
94
|
+
= hello_world
|
|
95
|
+
@abc
|
|
96
|
+
= hello_world
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
assert_html '<div class="hello world" id="notice" role="test">Hello World from @env</div><section role="abc">Hello World from @env</section>', source, shortcut: {'#' => {attr: 'id'}, '.' => {attr: 'class'}, '@' => {tag: 'section', attr: 'role'}}
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_render_with_custom_array_shortcut
|
|
103
|
+
source = %q{
|
|
104
|
+
#user@.admin Daniel
|
|
105
|
+
}
|
|
106
|
+
assert_html '<div class="admin" id="user" role="admin">Daniel</div>', source, shortcut: {'#' => {attr: 'id'}, '.' => {attr: 'class'}, '@' => {attr: 'role'}, '@.' => {attr: ['class', 'role']}}
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_render_with_custom_shortcut_and_additional_attrs
|
|
110
|
+
source = %q{
|
|
111
|
+
^items
|
|
112
|
+
== "[{'title':'item0'},{'title':'item1'},{'title':'item2'},{'title':'item3'},{'title':'item4'}]"
|
|
113
|
+
}
|
|
114
|
+
assert_html '<script data-binding="items" type="application/json">[{\'title\':\'item0\'},{\'title\':\'item1\'},{\'title\':\'item2\'},{\'title\':\'item3\'},{\'title\':\'item4\'}]</script>',
|
|
115
|
+
source, shortcut: {'^' => {tag: 'script', attr: 'data-binding', additional_attrs: { type: "application/json" }}}
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_render_with_custom_lambda_shortcut
|
|
119
|
+
begin
|
|
120
|
+
Slim::Parser.options[:shortcut]['~'] = {attr: ->(v) {{class: "styled-#{v}", id: "id-#{v}"}}}
|
|
121
|
+
source = %q{
|
|
122
|
+
~foo Hello
|
|
123
|
+
}
|
|
124
|
+
assert_html '<div class="styled-foo" id="id-foo">Hello</div>', source
|
|
125
|
+
ensure
|
|
126
|
+
Slim::Parser.options[:shortcut].delete('~')
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def test_render_with_custom_lambda_shortcut_and_multiple_values
|
|
131
|
+
begin
|
|
132
|
+
Slim::Parser.options[:shortcut]['~'] = {attr: ->(v) {{class: "styled-#{v}"}}}
|
|
133
|
+
source = %q{
|
|
134
|
+
~foo~bar Hello
|
|
135
|
+
}
|
|
136
|
+
assert_html '<div class="styled-foo styled-bar">Hello</div>', source
|
|
137
|
+
ensure
|
|
138
|
+
Slim::Parser.options[:shortcut].delete('~')
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_render_with_custom_lambda_shortcut_and_existing_class
|
|
143
|
+
begin
|
|
144
|
+
Slim::Parser.options[:shortcut]['~'] = {attr: ->(v) {{class: "styled-#{v}"}}}
|
|
145
|
+
source = %q{
|
|
146
|
+
~foo.baz Hello
|
|
147
|
+
}
|
|
148
|
+
assert_html '<div class="styled-foo baz">Hello</div>', source
|
|
149
|
+
ensure
|
|
150
|
+
Slim::Parser.options[:shortcut].delete('~')
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_render_with_existing_class_and_custom_lambda_shortcut
|
|
155
|
+
begin
|
|
156
|
+
Slim::Parser.options[:shortcut]['~'] = {attr: ->(v) {{class: "styled-#{v}"}}}
|
|
157
|
+
source = %q{
|
|
158
|
+
.baz~foo Hello
|
|
159
|
+
}
|
|
160
|
+
assert_html '<div class="baz styled-foo">Hello</div>', source
|
|
161
|
+
ensure
|
|
162
|
+
Slim::Parser.options[:shortcut].delete('~')
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def test_render_with_text_block
|
|
167
|
+
source = %q{
|
|
168
|
+
p
|
|
169
|
+
|
|
|
170
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
assert_html '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>', source
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def test_render_with_text_block_with_subsequent_markup
|
|
177
|
+
source = %q{
|
|
178
|
+
p
|
|
179
|
+
|
|
|
180
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
181
|
+
p Some more markup
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
assert_html '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p><p>Some more markup</p>', source
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def test_render_with_text_block_with_trailing_whitespace
|
|
188
|
+
source = %q{
|
|
189
|
+
' this is
|
|
190
|
+
a link to
|
|
191
|
+
a href="link" page
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
assert_html "this is\na link to <a href=\"link\">page</a>", source
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def test_nested_text
|
|
198
|
+
source = %q{
|
|
199
|
+
p
|
|
200
|
+
|
|
|
201
|
+
This is line one.
|
|
202
|
+
This is line two.
|
|
203
|
+
This is line three.
|
|
204
|
+
This is line four.
|
|
205
|
+
p This is a new paragraph.
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
assert_html "<p>This is line one.\n This is line two.\n This is line three.\n This is line four.</p><p>This is a new paragraph.</p>", source
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def test_nested_text_with_nested_html_one_same_line
|
|
212
|
+
source = %q{
|
|
213
|
+
p
|
|
214
|
+
| This is line one.
|
|
215
|
+
This is line two.
|
|
216
|
+
span.bold This is a bold line in the paragraph.
|
|
217
|
+
| This is more content.
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
assert_html "<p>This is line one.\n This is line two.<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_nested_text_with_nested_html_one_same_line2
|
|
224
|
+
source = %q{
|
|
225
|
+
p
|
|
226
|
+
|This is line one.
|
|
227
|
+
This is line two.
|
|
228
|
+
span.bold This is a bold line in the paragraph.
|
|
229
|
+
| This is more content.
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
assert_html "<p>This is line one.\n This is line two.<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def test_nested_text_with_nested_html
|
|
236
|
+
source = %q{
|
|
237
|
+
p
|
|
238
|
+
|
|
|
239
|
+
This is line one.
|
|
240
|
+
This is line two.
|
|
241
|
+
This is line three.
|
|
242
|
+
This is line four.
|
|
243
|
+
span.bold This is a bold line in the paragraph.
|
|
244
|
+
| This is more content.
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
assert_html "<p>This is line one.\n This is line two.\n This is line three.\n This is line four.<span class=\"bold\">This is a bold line in the paragraph.</span> This is more content.</p>", source
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def test_simple_paragraph_with_padding
|
|
251
|
+
source = %q{
|
|
252
|
+
p There will be 3 spaces in front of this line.
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
assert_html '<p> There will be 3 spaces in front of this line.</p>', source
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def test_paragraph_with_nested_text
|
|
259
|
+
source = %q{
|
|
260
|
+
p This is line one.
|
|
261
|
+
This is line two.
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
assert_html "<p>This is line one.\n This is line two.</p>", source
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def test_paragraph_with_padded_nested_text
|
|
268
|
+
source = %q{
|
|
269
|
+
p This is line one.
|
|
270
|
+
This is line two.
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
assert_html "<p> This is line one.\n This is line two.</p>", source
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def test_paragraph_with_attributes_and_nested_text
|
|
277
|
+
source = %q{
|
|
278
|
+
p#test class="paragraph" This is line one.
|
|
279
|
+
This is line two.
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
assert_html "<p class=\"paragraph\" id=\"test\">This is line one.\nThis is line two.</p>", source
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def test_relaxed_text_indentation
|
|
286
|
+
source = %q{
|
|
287
|
+
p
|
|
288
|
+
| text block
|
|
289
|
+
text
|
|
290
|
+
line3
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
assert_html "<p>text block\ntext\n line3</p>", source
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def test_output_code_with_leading_spaces
|
|
297
|
+
source = %q{
|
|
298
|
+
p= hello_world
|
|
299
|
+
p = hello_world
|
|
300
|
+
p = hello_world
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
assert_html '<p>Hello World from @env</p><p>Hello World from @env</p><p>Hello World from @env</p>', source
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def test_single_quoted_attributes
|
|
307
|
+
source = %q{
|
|
308
|
+
p class='underscored_class_name' = output_number
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
assert_html '<p class="underscored_class_name">1337</p>', source
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def test_nonstandard_attributes
|
|
315
|
+
source = %q{
|
|
316
|
+
p id="dashed-id" class="underscored_class_name" = output_number
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
assert_html '<p class="underscored_class_name" id="dashed-id">1337</p>', source
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def test_nonstandard_shortcut_attributes
|
|
323
|
+
source = %q{
|
|
324
|
+
p#dashed-id.underscored_class_name = output_number
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
assert_html '<p class="underscored_class_name" id="dashed-id">1337</p>', source
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def test_dashed_attributes
|
|
331
|
+
source = %q{
|
|
332
|
+
p data-info="Illudium Q-36" = output_number
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
assert_html '<p data-info="Illudium Q-36">1337</p>', source
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def test_dashed_attributes_with_shortcuts
|
|
339
|
+
source = %q{
|
|
340
|
+
p#marvin.martian data-info="Illudium Q-36" = output_number
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def test_parens_around_attributes
|
|
347
|
+
source = %q{
|
|
348
|
+
p(id="marvin" class="martian" data-info="Illudium Q-36") = output_number
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def test_square_brackets_around_attributes
|
|
355
|
+
source = %q{
|
|
356
|
+
p[id="marvin" class="martian" data-info="Illudium Q-36"] = output_number
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# Regression test for bug #796
|
|
363
|
+
def test_square_brackets_around_attributes_multiline_with_tabs
|
|
364
|
+
source = "div\n\tp[\n\t\tclass=\"martian\"\n\t]\n\tp Next line"
|
|
365
|
+
assert_html '<div><p class="martian"></p><p>Next line</p></div>', source
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
def test_parens_around_attributes_with_equal_sign_snug_to_right_paren
|
|
369
|
+
source = %q{
|
|
370
|
+
p(id="marvin" class="martian" data-info="Illudium Q-36")= output_number
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', source
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def test_default_attr_delims_option
|
|
377
|
+
source = %q{
|
|
378
|
+
p<id="marvin" class="martian" data-info="Illudium Q-36">= output_number
|
|
379
|
+
}
|
|
380
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
381
|
+
str = source.sub('<',k).sub('>',v)
|
|
382
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', str
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
def test_custom_attr_delims_option
|
|
387
|
+
source = %q{
|
|
388
|
+
p { foo="bar" }
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
assert_html '<p foo="bar"></p>', source
|
|
392
|
+
assert_html '<p foo="bar"></p>', source, attr_list_delims: {'{' => '}'}
|
|
393
|
+
assert_html '<p>{ foo="bar" }</p>', source, attr_list_delims: {'(' => ')', '[' => ']'}
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def test_closed_tag
|
|
397
|
+
source = %q{
|
|
398
|
+
closed/
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
assert_html '<closed />', source, format: :xhtml
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
def test_custom_attr_list_delims_option
|
|
405
|
+
source = %q{
|
|
406
|
+
p { foo="bar" x=(1+1) }
|
|
407
|
+
p < x=(1+1) > Hello
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
assert_html '<p foo="bar" x="2"></p><p>< x=(1+1) > Hello</p>', source
|
|
411
|
+
assert_html '<p foo="bar" x="2"></p><p>< x=(1+1) > Hello</p>', source, attr_list_delims: {'{' => '}'}
|
|
412
|
+
assert_html '<p>{ foo="bar" x=(1+1) }</p><p x="2">Hello</p>', source, attr_list_delims: {'<' => '>'}, code_attr_delims: { '(' => ')' }
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
def test_attributs_with_parens_and_spaces
|
|
416
|
+
source = %q{label{ for='filter' }= hello_world}
|
|
417
|
+
assert_html '<label for="filter">Hello World from @env</label>', source
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
def test_attributs_with_parens_and_spaces2
|
|
421
|
+
source = %q{label{ for='filter' } = hello_world}
|
|
422
|
+
assert_html '<label for="filter">Hello World from @env</label>', source
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
def test_attributs_with_multiple_spaces
|
|
426
|
+
source = %q{label for='filter' class="test" = hello_world}
|
|
427
|
+
assert_html '<label class="test" for="filter">Hello World from @env</label>', source
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def test_closed_tag_with_attributes
|
|
431
|
+
source = %q{
|
|
432
|
+
closed id="test" /
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
assert_html '<closed id="test" />', source, format: :xhtml
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
def test_closed_tag_with_attributes_and_parens
|
|
439
|
+
source = %q{
|
|
440
|
+
closed(id="test")/
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
assert_html '<closed id="test" />', source, format: :xhtml
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def test_render_with_html_comments
|
|
447
|
+
source = %q{
|
|
448
|
+
p Hello
|
|
449
|
+
/! This is a comment
|
|
450
|
+
|
|
451
|
+
Another comment
|
|
452
|
+
p World
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
assert_html "<p>Hello</p><!--This is a comment\n\nAnother comment--><p>World</p>", source
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def test_render_with_html_conditional_and_tag
|
|
459
|
+
source = %q{
|
|
460
|
+
/[ if IE ]
|
|
461
|
+
p Get a better browser.
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
assert_html "<!--[if IE]><p>Get a better browser.</p><![endif]-->", source
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
def test_render_with_html_conditional_and_method_output
|
|
468
|
+
source = %q{
|
|
469
|
+
/[ if IE ]
|
|
470
|
+
= message 'hello'
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
assert_html "<!--[if IE]>hello<![endif]-->", source
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
def test_multiline_attributes_with_method
|
|
477
|
+
source = %q{
|
|
478
|
+
p<id="marvin"
|
|
479
|
+
class="martian"
|
|
480
|
+
data-info="Illudium Q-36"> = output_number
|
|
481
|
+
}
|
|
482
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
483
|
+
str = source.sub('<',k).sub('>',v)
|
|
484
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">1337</p>', str
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def test_multiline_attributes_with_text_on_same_line
|
|
489
|
+
source = %q{
|
|
490
|
+
p<id="marvin"
|
|
491
|
+
class="martian"
|
|
492
|
+
data-info="Illudium Q-36"> THE space modulator
|
|
493
|
+
}
|
|
494
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
495
|
+
str = source.sub('<',k).sub('>',v)
|
|
496
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">THE space modulator</p>', str
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
def test_multiline_attributes_with_nested_text
|
|
501
|
+
source = %q{
|
|
502
|
+
p<id="marvin"
|
|
503
|
+
class="martian"
|
|
504
|
+
data-info="Illudium Q-36">
|
|
505
|
+
| THE space modulator
|
|
506
|
+
}
|
|
507
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
508
|
+
str = source.sub('<',k).sub('>',v)
|
|
509
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="marvin">THE space modulator</p>', str
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
def test_multiline_attributes_with_dynamic_attr
|
|
514
|
+
source = %q{
|
|
515
|
+
p<id=id_helper
|
|
516
|
+
class="martian"
|
|
517
|
+
data-info="Illudium Q-36">
|
|
518
|
+
| THE space modulator
|
|
519
|
+
}
|
|
520
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
521
|
+
str = source.sub('<',k).sub('>',v)
|
|
522
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="notice">THE space modulator</p>', str
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
def test_multiline_attributes_with_nested_tag
|
|
527
|
+
source = %q{
|
|
528
|
+
p<id=id_helper
|
|
529
|
+
class="martian"
|
|
530
|
+
data-info="Illudium Q-36">
|
|
531
|
+
span.emphasis THE
|
|
532
|
+
| space modulator
|
|
533
|
+
}
|
|
534
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
535
|
+
str = source.sub('<',k).sub('>',v)
|
|
536
|
+
assert_html '<p class="martian" data-info="Illudium Q-36" id="notice"><span class="emphasis">THE</span> space modulator</p>', str
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
def test_multiline_attributes_with_nested_text_and_extra_indentation
|
|
541
|
+
source = %q{
|
|
542
|
+
li< id="myid"
|
|
543
|
+
class="myclass"
|
|
544
|
+
data-info="myinfo">
|
|
545
|
+
a href="link" My Link
|
|
546
|
+
}
|
|
547
|
+
Slim::Parser.options[:attr_list_delims].each do |k,v|
|
|
548
|
+
str = source.sub('<',k).sub('>',v)
|
|
549
|
+
assert_html '<li class="myclass" data-info="myinfo" id="myid"><a href="link">My Link</a></li>', str
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
def test_block_expansion_support
|
|
554
|
+
source = %q{
|
|
555
|
+
ul
|
|
556
|
+
li.first: a href='a' foo
|
|
557
|
+
li: a href='b' bar
|
|
558
|
+
li.last: a href='c' baz
|
|
559
|
+
}
|
|
560
|
+
assert_html %{<ul><li class=\"first\"><a href=\"a\">foo</a></li><li><a href=\"b\">bar</a></li><li class=\"last\"><a href=\"c\">baz</a></li></ul>}, source
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
def test_block_expansion_class_attributes
|
|
564
|
+
source = %q{
|
|
565
|
+
.a: .b: #c d
|
|
566
|
+
}
|
|
567
|
+
assert_html %{<div class="a"><div class="b"><div id="c">d</div></div></div>}, source
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
def test_block_expansion_nesting
|
|
571
|
+
source = %q{
|
|
572
|
+
html: body: .content
|
|
573
|
+
| Text
|
|
574
|
+
}
|
|
575
|
+
assert_html %{<html><body><div class=\"content\">Text</div></body></html>}, source
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
def test_eval_attributes_once
|
|
579
|
+
source = %q{
|
|
580
|
+
input[value=succ_x]
|
|
581
|
+
input[value=succ_x]
|
|
582
|
+
}
|
|
583
|
+
assert_html %{<input value="1" /><input value="2" />}, source
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
def test_html_line_indicator
|
|
587
|
+
source = %q{
|
|
588
|
+
<html>
|
|
589
|
+
head
|
|
590
|
+
meta name="keywords" content=hello_world
|
|
591
|
+
- if true
|
|
592
|
+
<p>#{hello_world}</p>
|
|
593
|
+
span = hello_world
|
|
594
|
+
</html>
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
assert_html '<html><head><meta content="Hello World from @env" name="keywords" /></head><p>Hello World from @env</p><span>Hello World from @env</span></html>', source
|
|
598
|
+
end
|
|
599
|
+
end
|