mini-max-gem 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/mini-max-gem.gemspec +11 -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 +164 -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
- metadata +165 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestSlimCodeEvaluation < TestSlim
|
|
4
|
+
def test_render_with_call_to_set_attributes
|
|
5
|
+
source = %q{
|
|
6
|
+
p id="#{id_helper}" class="hello world" = hello_world
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
assert_html '<p class="hello world" id="notice">Hello World from @env</p>', source
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_render_with_call_to_set_custom_attributes
|
|
13
|
+
source = %q{
|
|
14
|
+
p data-id="#{id_helper}" data-class="hello world"
|
|
15
|
+
= hello_world
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
assert_html '<p data-class="hello world" data-id="notice">Hello World from @env</p>', source
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_render_with_call_to_set_attributes_and_call_to_set_content
|
|
22
|
+
source = %q{
|
|
23
|
+
p id="#{id_helper}" class="hello world" = hello_world
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
assert_html '<p class="hello world" id="notice">Hello World from @env</p>', source
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_render_with_parameterized_call_to_set_attributes_and_call_to_set_content
|
|
30
|
+
source = %q{
|
|
31
|
+
p id="#{id_helper}" class="hello world" = hello_world("Hello Ruby!")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
assert_html '<p class="hello world" id="notice">Hello Ruby!</p>', source
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_render_with_spaced_parameterized_call_to_set_attributes_and_call_to_set_content
|
|
38
|
+
source = %q{
|
|
39
|
+
p id="#{id_helper}" class="hello world" = hello_world "Hello Ruby!"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
assert_html '<p class="hello world" id="notice">Hello Ruby!</p>', source
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_render_with_spaced_parameterized_call_to_set_attributes_and_call_to_set_content_2
|
|
46
|
+
source = %q{
|
|
47
|
+
p id="#{id_helper}" class="hello world" = hello_world "Hello Ruby!", dummy: "value"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
assert_html '<p class="hello world" id="notice">Hello Ruby!dummy value</p>', source
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_hash_call_in_attribute
|
|
54
|
+
source = %q{
|
|
55
|
+
p id="#{hash[:a]}" Test it
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
assert_html '<p id="The letter a">Test it</p>', source
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_instance_variable_in_attribute_without_quotes
|
|
62
|
+
source = %q{
|
|
63
|
+
p id=@var
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
assert_html '<p id="instance"></p>', source
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_method_call_in_attribute_without_quotes
|
|
70
|
+
source = %q{
|
|
71
|
+
form action=action_path(:page, :save) method='post'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
assert_html '<form action="/action-page-save" method="post"></form>', source
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_ruby_attribute_with_unbalanced_delimiters
|
|
78
|
+
source = %q{
|
|
79
|
+
div crazy=action_path('[') id="crazy_delimiters"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
assert_html '<div crazy="/action-[" id="crazy_delimiters"></div>', source
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_method_call_in_delimited_attribute_without_quotes
|
|
86
|
+
source = %q{
|
|
87
|
+
form(action=action_path(:page, :save) method='post')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assert_html '<form action="/action-page-save" method="post"></form>', source
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_method_call_in_delimited_attribute_without_quotes2
|
|
94
|
+
source = %q{
|
|
95
|
+
form(method='post' action=action_path(:page, :save))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
assert_html '<form action="/action-page-save" method="post"></form>', source
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_hash_call_in_attribute_without_quotes
|
|
102
|
+
source = %q{
|
|
103
|
+
p id=hash[:a] Test it
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
assert_html '<p id="The letter a">Test it</p>', source
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_hash_call_in_delimited_attribute
|
|
110
|
+
source = %q{
|
|
111
|
+
p(id=hash[:a]) Test it
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
assert_html '<p id="The letter a">Test it</p>', source
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_hash_call_in_attribute_with_ruby_evaluation
|
|
118
|
+
source = %q{
|
|
119
|
+
p id=(hash[:a] + hash[:a]) Test it
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
assert_html '<p id="The letter aThe letter a">Test it</p>', source
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_hash_call_in_delimited_attribute_with_ruby_evaluation
|
|
126
|
+
source = %q{
|
|
127
|
+
p(id=(hash[:a] + hash[:a])) Test it
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
assert_html '<p id="The letter aThe letter a">Test it</p>', source
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_hash_call_in_delimited_attribute_with_ruby_evaluation_2
|
|
134
|
+
source = %q{
|
|
135
|
+
p[id=(hash[:a] + hash[:a])] Test it
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
assert_html '<p id="The letter aThe letter a">Test it</p>', source
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_hash_call_in_delimited_attribute_with_ruby_evaluation_3
|
|
142
|
+
source = %q{
|
|
143
|
+
p(id=(hash[:a] + hash[:a]) class=hash[:a]) Test it
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
assert_html '<p class="The letter a" id="The letter aThe letter a">Test it</p>', source
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_hash_call_in_delimited_attribute_with_ruby_evaluation_4_
|
|
150
|
+
source = %q{
|
|
151
|
+
p(id=hash[:a] class=hash[:a]) Test it
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
assert_html '<p class="The letter a" id="The letter a">Test it</p>', source
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_computation_in_attribute
|
|
158
|
+
source = %q{
|
|
159
|
+
p id=(1 + 1)*5 Test it
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
assert_html '<p id="10">Test it</p>', source
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_code_attribute_does_not_modify_argument
|
|
166
|
+
require 'ostruct'
|
|
167
|
+
template = 'span class=attribute'
|
|
168
|
+
model = OpenStruct.new(attribute: [:a, :b, [:c, :d]])
|
|
169
|
+
output = Slim::Template.new { template }.render(model)
|
|
170
|
+
assert_equal('<span class="a b c d"></span>', output)
|
|
171
|
+
assert_equal([:a, :b, [:c, :d]], model.attribute)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_number_type_interpolation
|
|
175
|
+
source = %q{
|
|
176
|
+
p = output_number
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
assert_html '<p>1337</p>', source
|
|
180
|
+
end
|
|
181
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestSlimCodeOutput < TestSlim
|
|
4
|
+
def test_render_with_call
|
|
5
|
+
source = %q{
|
|
6
|
+
p
|
|
7
|
+
= hello_world
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
assert_html '<p>Hello World from @env</p>', source
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_render_with_trailing_whitespace
|
|
14
|
+
source = %q{
|
|
15
|
+
p
|
|
16
|
+
=> hello_world
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
assert_html '<p>Hello World from @env </p>', source
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_render_with_trailing_whitespace_after_tag
|
|
23
|
+
source = %q{
|
|
24
|
+
p=> hello_world
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
assert_html '<p>Hello World from @env</p> ', source
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_no_escape_render_with_trailing_whitespace
|
|
31
|
+
source = %q{
|
|
32
|
+
p
|
|
33
|
+
==> hello_world
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
assert_html '<p>Hello World from @env </p>', source
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_no_escape_render_with_trailing_whitespace_after_tag
|
|
40
|
+
source = %q{
|
|
41
|
+
p==> hello_world
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
assert_html '<p>Hello World from @env</p> ', source
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_render_with_conditional_call
|
|
48
|
+
source = %q{
|
|
49
|
+
p
|
|
50
|
+
= hello_world if true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
assert_html '<p>Hello World from @env</p>', source
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_render_with_parameterized_call
|
|
57
|
+
source = %q{
|
|
58
|
+
p
|
|
59
|
+
= hello_world("Hello Ruby!")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
assert_html '<p>Hello Ruby!</p>', source
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_render_with_spaced_parameterized_call
|
|
66
|
+
source = %q{
|
|
67
|
+
p
|
|
68
|
+
= hello_world "Hello Ruby!"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
assert_html '<p>Hello Ruby!</p>', source
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_render_with_spaced_parameterized_call_2
|
|
75
|
+
source = %q{
|
|
76
|
+
p
|
|
77
|
+
= hello_world "Hello Ruby!", dummy: "value"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
assert_html '<p>Hello Ruby!dummy value</p>', source
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_render_with_call_and_inline_text
|
|
84
|
+
source = %q{
|
|
85
|
+
h1 This is my title
|
|
86
|
+
p
|
|
87
|
+
= hello_world
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
assert_html '<h1>This is my title</h1><p>Hello World from @env</p>', source
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_render_with_attribute_starts_with_keyword
|
|
94
|
+
source = %q{
|
|
95
|
+
p = hello_world in_keyword
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
assert_html '<p>starts with keyword</p>', source
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_hash_call
|
|
102
|
+
source = %q{
|
|
103
|
+
p = hash[:a]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
assert_html '<p>The letter a</p>', source
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_tag_output_without_space
|
|
110
|
+
source = %q{
|
|
111
|
+
p= hello_world
|
|
112
|
+
p=hello_world
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
assert_html '<p>Hello World from @env</p><p>Hello World from @env</p>', source
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_class_output_without_space
|
|
119
|
+
source = %q{
|
|
120
|
+
.test=hello_world
|
|
121
|
+
#test==hello_world
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
assert_html '<div class="test">Hello World from @env</div><div id="test">Hello World from @env</div>', source
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_attribute_output_without_space
|
|
128
|
+
source = %q{
|
|
129
|
+
p id="test"=hello_world
|
|
130
|
+
p(id="test")==hello_world
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
assert_html '<p id="test">Hello World from @env</p><p id="test">Hello World from @env</p>', source
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_render_with_backslash_end
|
|
137
|
+
# Keep trailing spaces!
|
|
138
|
+
source = %q{
|
|
139
|
+
p = \
|
|
140
|
+
"Hello" + \
|
|
141
|
+
" Ruby!"
|
|
142
|
+
- variable = 1 + \
|
|
143
|
+
2 + \
|
|
144
|
+
3
|
|
145
|
+
= variable + \
|
|
146
|
+
1
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
assert_html '<p>Hello Ruby!</p>7', source
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_render_with_comma_end
|
|
153
|
+
source = %q{
|
|
154
|
+
p = message("Hello",
|
|
155
|
+
"Ruby!")
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
assert_html '<p>Hello Ruby!</p>', source
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def test_render_with_no_trailing_character
|
|
162
|
+
source = %q{
|
|
163
|
+
p
|
|
164
|
+
= hello_world}
|
|
165
|
+
|
|
166
|
+
assert_html '<p>Hello World from @env</p>', source
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestSlimCodeStructure < TestSlim
|
|
4
|
+
def test_render_with_conditional
|
|
5
|
+
source = %q{
|
|
6
|
+
div
|
|
7
|
+
- if show_first?
|
|
8
|
+
p The first paragraph
|
|
9
|
+
- else
|
|
10
|
+
p The second paragraph
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
assert_html '<div><p>The second paragraph</p></div>', source
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_render_with_begin
|
|
17
|
+
source = %q{
|
|
18
|
+
- if true
|
|
19
|
+
- begin
|
|
20
|
+
p A
|
|
21
|
+
- if true
|
|
22
|
+
- begin
|
|
23
|
+
p B
|
|
24
|
+
- if true
|
|
25
|
+
- begin
|
|
26
|
+
p C
|
|
27
|
+
- rescue
|
|
28
|
+
p D
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
assert_html '<p>A</p><p>B</p><p>C</p>', source
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_render_with_consecutive_conditionals
|
|
35
|
+
source = %q{
|
|
36
|
+
div
|
|
37
|
+
- if show_first? true
|
|
38
|
+
p The first paragraph
|
|
39
|
+
- if show_first? true
|
|
40
|
+
p The second paragraph
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
assert_html '<div><p>The first paragraph</p><p>The second paragraph</p></div>', source
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_render_with_parameterized_conditional
|
|
47
|
+
source = %q{
|
|
48
|
+
div
|
|
49
|
+
- if show_first? false
|
|
50
|
+
p The first paragraph
|
|
51
|
+
- else
|
|
52
|
+
p The second paragraph
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
assert_html '<div><p>The second paragraph</p></div>', source
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_render_with_when_string_in_condition
|
|
59
|
+
source = %q{
|
|
60
|
+
- if true
|
|
61
|
+
| Hello
|
|
62
|
+
|
|
63
|
+
- unless 'when' == nil
|
|
64
|
+
| world
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
assert_html 'Hello world', source
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_render_with_conditional_and_following_nonconditonal
|
|
71
|
+
source = %q{
|
|
72
|
+
div
|
|
73
|
+
- if true
|
|
74
|
+
p The first paragraph
|
|
75
|
+
- var = 42
|
|
76
|
+
= var
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
assert_html '<div><p>The first paragraph</p>42</div>', source
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_render_with_inline_condition
|
|
83
|
+
source = %q{
|
|
84
|
+
p = hello_world if true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
assert_html '<p>Hello World from @env</p>', source
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_render_with_case
|
|
91
|
+
source = %q{
|
|
92
|
+
p
|
|
93
|
+
- case 42
|
|
94
|
+
- when 41
|
|
95
|
+
| 41
|
|
96
|
+
- when 42
|
|
97
|
+
| 42
|
|
98
|
+
| is the answer
|
|
99
|
+
p
|
|
100
|
+
- case 41
|
|
101
|
+
- when 41
|
|
102
|
+
| 41
|
|
103
|
+
- when 42
|
|
104
|
+
| 42
|
|
105
|
+
| is the answer
|
|
106
|
+
p
|
|
107
|
+
- case 42 when 41
|
|
108
|
+
| 41
|
|
109
|
+
- when 42
|
|
110
|
+
| 42
|
|
111
|
+
| is the answer
|
|
112
|
+
p
|
|
113
|
+
- case 41 when 41
|
|
114
|
+
| 41
|
|
115
|
+
- when 42
|
|
116
|
+
| 42
|
|
117
|
+
| is the answer
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
assert_html '<p>42 is the answer</p><p>41 is the answer</p><p>42 is the answer</p><p>41 is the answer</p>', source
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7")
|
|
124
|
+
def test_render_with_case_in
|
|
125
|
+
source = %q{
|
|
126
|
+
p
|
|
127
|
+
- case [:greet, "world"]
|
|
128
|
+
- in :greet, value if false
|
|
129
|
+
= "Goodbye #{value}"
|
|
130
|
+
- in :greet, value unless true
|
|
131
|
+
= "Top of the morning to you, #{value}"
|
|
132
|
+
- in :greet, value
|
|
133
|
+
= "Hello #{value}"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
assert_html '<p>Hello world</p>', source
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def test_render_with_slim_comments
|
|
141
|
+
source = %q{
|
|
142
|
+
p Hello
|
|
143
|
+
/ This is a comment
|
|
144
|
+
Another comment
|
|
145
|
+
p World
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
assert_html '<p>Hello</p><p>World</p>', source
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def test_render_with_yield
|
|
152
|
+
source = %q{
|
|
153
|
+
div
|
|
154
|
+
== yield :menu
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
assert_html '<div>This is the menu</div>', source do
|
|
158
|
+
'This is the menu'
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def test_render_with_begin_rescue
|
|
163
|
+
source = %q{
|
|
164
|
+
- begin
|
|
165
|
+
p Begin
|
|
166
|
+
- rescue
|
|
167
|
+
p Rescue
|
|
168
|
+
p After
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
assert_html '<p>Begin</p><p>After</p>', source
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_render_with_begin_rescue_exception
|
|
175
|
+
source = %q{
|
|
176
|
+
- begin
|
|
177
|
+
p Begin
|
|
178
|
+
- raise 'Boom'
|
|
179
|
+
p After Boom
|
|
180
|
+
- rescue => ex
|
|
181
|
+
p = ex.message
|
|
182
|
+
p After
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
assert_html '<p>Begin</p><p>Boom</p><p>After</p>', source
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def test_render_with_begin_rescue_ensure
|
|
189
|
+
source = %q{
|
|
190
|
+
- begin
|
|
191
|
+
p Begin
|
|
192
|
+
- raise 'Boom'
|
|
193
|
+
p After Boom
|
|
194
|
+
- rescue => ex
|
|
195
|
+
p = ex.message
|
|
196
|
+
- ensure
|
|
197
|
+
p Ensure
|
|
198
|
+
p After
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
assert_html '<p>Begin</p><p>Boom</p><p>Ensure</p><p>After</p>', source
|
|
202
|
+
end
|
|
203
|
+
end
|