mega-quick-lib 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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/mega-quick-lib.gemspec +12 -0
  3. data/slim-5.2.1/CHANGES +496 -0
  4. data/slim-5.2.1/Gemfile +43 -0
  5. data/slim-5.2.1/LICENSE +21 -0
  6. data/slim-5.2.1/README.jp.md +1276 -0
  7. data/slim-5.2.1/README.md +1313 -0
  8. data/slim-5.2.1/Rakefile +80 -0
  9. data/slim-5.2.1/bin/slimrb +6 -0
  10. data/slim-5.2.1/doc/include.md +20 -0
  11. data/slim-5.2.1/doc/jp/include.md +20 -0
  12. data/slim-5.2.1/doc/jp/logic_less.md +137 -0
  13. data/slim-5.2.1/doc/jp/smart.md +102 -0
  14. data/slim-5.2.1/doc/jp/translator.md +28 -0
  15. data/slim-5.2.1/doc/logic_less.md +137 -0
  16. data/slim-5.2.1/doc/smart.md +120 -0
  17. data/slim-5.2.1/doc/translator.md +28 -0
  18. data/slim-5.2.1/lib/slim/code_attributes.rb +68 -0
  19. data/slim-5.2.1/lib/slim/command.rb +122 -0
  20. data/slim-5.2.1/lib/slim/controls.rb +61 -0
  21. data/slim-5.2.1/lib/slim/do_inserter.rb +34 -0
  22. data/slim-5.2.1/lib/slim/embedded.rb +248 -0
  23. data/slim-5.2.1/lib/slim/end_inserter.rb +63 -0
  24. data/slim-5.2.1/lib/slim/engine.rb +42 -0
  25. data/slim-5.2.1/lib/slim/erb_converter.rb +15 -0
  26. data/slim-5.2.1/lib/slim/filter.rb +31 -0
  27. data/slim-5.2.1/lib/slim/grammar.rb +24 -0
  28. data/slim-5.2.1/lib/slim/include.rb +58 -0
  29. data/slim-5.2.1/lib/slim/interpolation.rb +36 -0
  30. data/slim-5.2.1/lib/slim/logic_less/context.rb +126 -0
  31. data/slim-5.2.1/lib/slim/logic_less/filter.rb +81 -0
  32. data/slim-5.2.1/lib/slim/logic_less.rb +6 -0
  33. data/slim-5.2.1/lib/slim/parser.rb +535 -0
  34. data/slim-5.2.1/lib/slim/railtie.rb +19 -0
  35. data/slim-5.2.1/lib/slim/smart/escaper.rb +42 -0
  36. data/slim-5.2.1/lib/slim/smart/filter.rb +97 -0
  37. data/slim-5.2.1/lib/slim/smart/parser.rb +35 -0
  38. data/slim-5.2.1/lib/slim/smart.rb +9 -0
  39. data/slim-5.2.1/lib/slim/splat/builder.rb +115 -0
  40. data/slim-5.2.1/lib/slim/splat/filter.rb +93 -0
  41. data/slim-5.2.1/lib/slim/template.rb +6 -0
  42. data/slim-5.2.1/lib/slim/translator.rb +119 -0
  43. data/slim-5.2.1/lib/slim/version.rb +6 -0
  44. data/slim-5.2.1/lib/slim.rb +16 -0
  45. data/slim-5.2.1/slim.gemspec +33 -0
  46. data/slim-5.2.1/test/core/helper.rb +201 -0
  47. data/slim-5.2.1/test/core/test_code_blocks.rb +194 -0
  48. data/slim-5.2.1/test/core/test_code_escaping.rb +162 -0
  49. data/slim-5.2.1/test/core/test_code_evaluation.rb +181 -0
  50. data/slim-5.2.1/test/core/test_code_output.rb +168 -0
  51. data/slim-5.2.1/test/core/test_code_structure.rb +203 -0
  52. data/slim-5.2.1/test/core/test_commands.rb +219 -0
  53. data/slim-5.2.1/test/core/test_embedded_engines.rb +247 -0
  54. data/slim-5.2.1/test/core/test_encoding.rb +28 -0
  55. data/slim-5.2.1/test/core/test_erb_converter.rb +65 -0
  56. data/slim-5.2.1/test/core/test_html_attributes.rb +276 -0
  57. data/slim-5.2.1/test/core/test_html_escaping.rb +65 -0
  58. data/slim-5.2.1/test/core/test_html_structure.rb +599 -0
  59. data/slim-5.2.1/test/core/test_parser_errors.rb +148 -0
  60. data/slim-5.2.1/test/core/test_pretty.rb +163 -0
  61. data/slim-5.2.1/test/core/test_ruby_errors.rb +200 -0
  62. data/slim-5.2.1/test/core/test_slim_template.rb +78 -0
  63. data/slim-5.2.1/test/core/test_splat_prefix_option.rb +155 -0
  64. data/slim-5.2.1/test/core/test_tabs.rb +169 -0
  65. data/slim-5.2.1/test/core/test_text_interpolation.rb +79 -0
  66. data/slim-5.2.1/test/core/test_thread_options.rb +18 -0
  67. data/slim-5.2.1/test/core/test_unicode.rb +15 -0
  68. data/slim-5.2.1/test/include/files/recursive.slim +1 -0
  69. data/slim-5.2.1/test/include/files/slimfile.slim +3 -0
  70. data/slim-5.2.1/test/include/files/subdir/test.slim +1 -0
  71. data/slim-5.2.1/test/include/files/textfile +1 -0
  72. data/slim-5.2.1/test/include/test_include.rb +24 -0
  73. data/slim-5.2.1/test/literate/TESTS.md +1323 -0
  74. data/slim-5.2.1/test/literate/helper.rb +15 -0
  75. data/slim-5.2.1/test/literate/run.rb +92 -0
  76. data/slim-5.2.1/test/logic_less/test_logic_less.rb +330 -0
  77. data/slim-5.2.1/test/rails/Rakefile +7 -0
  78. data/slim-5.2.1/test/rails/app/assets/config/manifest.js +1 -0
  79. data/slim-5.2.1/test/rails/app/controllers/application_controller.rb +2 -0
  80. data/slim-5.2.1/test/rails/app/controllers/entries_controller.rb +5 -0
  81. data/slim-5.2.1/test/rails/app/controllers/slim_controller.rb +46 -0
  82. data/slim-5.2.1/test/rails/app/helpers/application_helper.rb +5 -0
  83. data/slim-5.2.1/test/rails/app/models/entry.rb +16 -0
  84. data/slim-5.2.1/test/rails/app/views/entries/edit.html.slim +3 -0
  85. data/slim-5.2.1/test/rails/app/views/layouts/application.html+testvariant.slim +10 -0
  86. data/slim-5.2.1/test/rails/app/views/layouts/application.html.slim +10 -0
  87. data/slim-5.2.1/test/rails/app/views/slim/_partial.html.slim +1 -0
  88. data/slim-5.2.1/test/rails/app/views/slim/attributes.html.slim +3 -0
  89. data/slim-5.2.1/test/rails/app/views/slim/content_for.html.slim +7 -0
  90. data/slim-5.2.1/test/rails/app/views/slim/erb.html.erb +1 -0
  91. data/slim-5.2.1/test/rails/app/views/slim/form_for.html.slim +2 -0
  92. data/slim-5.2.1/test/rails/app/views/slim/helper.html.slim +4 -0
  93. data/slim-5.2.1/test/rails/app/views/slim/integers.html.slim +1 -0
  94. data/slim-5.2.1/test/rails/app/views/slim/no_layout.html.slim +1 -0
  95. data/slim-5.2.1/test/rails/app/views/slim/normal.html.slim +1 -0
  96. data/slim-5.2.1/test/rails/app/views/slim/partial.html.slim +2 -0
  97. data/slim-5.2.1/test/rails/app/views/slim/splat.html.slim +2 -0
  98. data/slim-5.2.1/test/rails/app/views/slim/splat_with_delimiter.slim +1 -0
  99. data/slim-5.2.1/test/rails/app/views/slim/thread_options.html.slim +1 -0
  100. data/slim-5.2.1/test/rails/app/views/slim/variables.html.slim +1 -0
  101. data/slim-5.2.1/test/rails/app/views/slim/xml.slim +1 -0
  102. data/slim-5.2.1/test/rails/config/application.rb +44 -0
  103. data/slim-5.2.1/test/rails/config/boot.rb +10 -0
  104. data/slim-5.2.1/test/rails/config/environment.rb +5 -0
  105. data/slim-5.2.1/test/rails/config/environments/test.rb +34 -0
  106. data/slim-5.2.1/test/rails/config/initializers/backtrace_silencers.rb +7 -0
  107. data/slim-5.2.1/test/rails/config/initializers/inflections.rb +10 -0
  108. data/slim-5.2.1/test/rails/config/initializers/mime_types.rb +5 -0
  109. data/slim-5.2.1/test/rails/config/initializers/session_store.rb +8 -0
  110. data/slim-5.2.1/test/rails/config/locales/en.yml +5 -0
  111. data/slim-5.2.1/test/rails/config/routes.rb +60 -0
  112. data/slim-5.2.1/test/rails/config.ru +4 -0
  113. data/slim-5.2.1/test/rails/script/rails +6 -0
  114. data/slim-5.2.1/test/rails/test/helper.rb +34 -0
  115. data/slim-5.2.1/test/rails/test/test_slim.rb +102 -0
  116. data/slim-5.2.1/test/sinatra/contest.rb +91 -0
  117. data/slim-5.2.1/test/sinatra/helper.rb +143 -0
  118. data/slim-5.2.1/test/sinatra/test_core.rb +91 -0
  119. data/slim-5.2.1/test/sinatra/test_include.rb +16 -0
  120. data/slim-5.2.1/test/sinatra/views/embed_include_js.slim +8 -0
  121. data/slim-5.2.1/test/sinatra/views/embed_js.slim +11 -0
  122. data/slim-5.2.1/test/sinatra/views/footer.slim +1 -0
  123. data/slim-5.2.1/test/sinatra/views/hello.slim +1 -0
  124. data/slim-5.2.1/test/sinatra/views/layout2.slim +3 -0
  125. data/slim-5.2.1/test/smart/test_smart_text.rb +294 -0
  126. data/slim-5.2.1/test/translator/test_translator.rb +76 -0
  127. metadata +166 -0
@@ -0,0 +1,194 @@
1
+ require 'helper'
2
+
3
+ class TestSlimCodeBlocks < TestSlim
4
+ def test_render_with_output_code_block
5
+ source = %q{
6
+ p
7
+ = hello_world "Hello Ruby!" do
8
+ | Hello from within a block!
9
+ }
10
+
11
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
12
+ end
13
+
14
+ def test_render_with_output_code_block_without_do
15
+ source = %q{
16
+ p
17
+ = hello_world "Hello Ruby!"
18
+ | Hello from within a block!
19
+ }
20
+
21
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
22
+ end
23
+
24
+ def test_render_variable_ending_with_do
25
+ source = %q{
26
+ - appelido=10
27
+ p= appelido
28
+ - appelido
29
+ }
30
+
31
+ assert_html '<p>10</p>', source
32
+ end
33
+
34
+
35
+ def test_render_with_output_code_within_block
36
+ source = %q{
37
+ p
38
+ = hello_world "Hello Ruby!" do
39
+ = hello_world "Hello from within a block!"
40
+ }
41
+
42
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
43
+ end
44
+
45
+ def test_render_with_output_code_within_block_without_do
46
+ source = %q{
47
+ p
48
+ = hello_world "Hello Ruby!"
49
+ = hello_world "Hello from within a block!"
50
+ }
51
+
52
+ assert_html '<p>Hello Ruby! Hello from within a block! Hello Ruby!</p>', source
53
+ end
54
+
55
+ def test_render_with_output_code_within_block_2
56
+ source = %q{
57
+ p
58
+ = hello_world "Hello Ruby!" do
59
+ = hello_world "Hello from within a block!" do
60
+ = hello_world "And another one!"
61
+ }
62
+
63
+ assert_html '<p>Hello Ruby! Hello from within a block! And another one! Hello from within a block! Hello Ruby!</p>', source
64
+ end
65
+
66
+ def test_render_with_output_code_within_block_2_without_do
67
+ source = %q{
68
+ p
69
+ = hello_world "Hello Ruby!"
70
+ = hello_world "Hello from within a block!"
71
+ = hello_world "And another one!"
72
+ }
73
+
74
+ assert_html '<p>Hello Ruby! Hello from within a block! And another one! Hello from within a block! Hello Ruby!</p>', source
75
+ end
76
+
77
+ def test_output_block_with_arguments
78
+ source = %q{
79
+ p
80
+ = define_macro :person do |first_name, last_name|
81
+ .first_name = first_name
82
+ .last_name = last_name
83
+ == call_macro :person, 'John', 'Doe'
84
+ == call_macro :person, 'Max', 'Mustermann'
85
+ }
86
+
87
+ assert_html '<p><div class="first_name">John</div><div class="last_name">Doe</div><div class="first_name">Max</div><div class="last_name">Mustermann</div></p>', source
88
+ end
89
+
90
+
91
+ def test_render_with_control_code_loop
92
+ source = %q{
93
+ p
94
+ - 3.times do
95
+ | Hey!
96
+ }
97
+
98
+ assert_html '<p>Hey!Hey!Hey!</p>', source
99
+ end
100
+
101
+ def test_render_with_control_code_loop_without_do
102
+ source = %q{
103
+ p
104
+ - 3.times
105
+ | Hey!
106
+ }
107
+
108
+ assert_html '<p>Hey!Hey!Hey!</p>', source
109
+ end
110
+
111
+ def test_captured_code_block_with_conditional
112
+ source = %q{
113
+ = hello_world "Hello Ruby!" do
114
+ - if true
115
+ | Hello from within a block!
116
+ }
117
+
118
+ assert_html 'Hello Ruby! Hello from within a block! Hello Ruby!', source
119
+ end
120
+
121
+ def test_captured_code_block_with_conditional_without_do
122
+ source = %q{
123
+ = hello_world "Hello Ruby!"
124
+ - if true
125
+ | Hello from within a block!
126
+ }
127
+
128
+ assert_html 'Hello Ruby! Hello from within a block! Hello Ruby!', source
129
+ end
130
+
131
+ def test_if_without_content
132
+ source = %q{
133
+ - if true
134
+ }
135
+ assert_html '', source
136
+ end
137
+
138
+ def test_unless_without_content
139
+ source = %q{
140
+ - unless true
141
+ }
142
+ assert_html '', source
143
+ end
144
+
145
+ def test_if_with_comment
146
+ source = %q{
147
+ - if true
148
+ / comment
149
+ }
150
+ assert_html '', source
151
+ end
152
+
153
+ def test_control_do_with_comment
154
+ source = %q{
155
+ - hello_world "Hello"
156
+ / comment
157
+ }
158
+ assert_html '', source
159
+ end
160
+
161
+ def test_output_do_with_comment
162
+ source = %q{
163
+ = hello_world "Hello"
164
+ / comment
165
+ }
166
+ assert_html 'Hello', source
167
+ end
168
+
169
+ def test_output_if_without_content
170
+ source = %q{
171
+ = if true
172
+ }
173
+ assert_html '', source
174
+ end
175
+
176
+ def test_output_if_with_comment
177
+ source = %q{
178
+ = if true
179
+ / comment
180
+ }
181
+ assert_html '', source
182
+ end
183
+
184
+ def test_output_format_with_if
185
+ source = %q{
186
+ h3.subtitle
187
+ - if true
188
+ a href="#" Title true
189
+ - else
190
+ a href="#" Title false
191
+ }
192
+ assert_html '<h3 class="subtitle"><a href="#">Title true</a></h3>', source
193
+ end
194
+ end
@@ -0,0 +1,162 @@
1
+ require 'helper'
2
+
3
+ class TestSlimCodeEscaping < TestSlim
4
+ def test_escaping_evil_method
5
+ source = %q{
6
+ p = evil_method
7
+ }
8
+
9
+ assert_html '<p>&lt;script&gt;do_something_evil();&lt;/script&gt;</p>', source
10
+ end
11
+
12
+ def test_render_without_html_safe
13
+ source = %q{
14
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
15
+ }
16
+
17
+ assert_html "<p>&lt;strong&gt;Hello World\n, meet \&quot;Slim\&quot;&lt;/strong&gt;.</p>", source
18
+ end
19
+
20
+ def test_render_without_html_safe2
21
+ source = %q{
22
+ p = "<strong>Hello World\\n, meet 'Slim'</strong>."
23
+ }
24
+
25
+ assert_html "<p>&lt;strong&gt;Hello World\n, meet &#39;Slim&#39;&lt;/strong&gt;.</p>", source
26
+ end
27
+
28
+ def test_render_with_html_safe_false
29
+ source = %q{
30
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
31
+ }
32
+
33
+ with_html_safe do
34
+ assert_html "<p>&lt;strong&gt;Hello World\n, meet \&quot;Slim\&quot;&lt;/strong&gt;.</p>", source, use_html_safe: true
35
+ end
36
+ end
37
+
38
+ def test_render_with_html_safe_true
39
+ source = %q{
40
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>.".html_safe
41
+ }
42
+
43
+ with_html_safe do
44
+ assert_html "<p><strong>Hello World\n, meet \"Slim\"</strong>.</p>", source, use_html_safe: true
45
+ end
46
+ end
47
+
48
+ def test_render_splat_with_html_safe_true
49
+ source = %q{
50
+ p *{ title: '&amp;'.html_safe }
51
+ }
52
+
53
+ with_html_safe do
54
+ assert_html "<p title=\"&amp;\"></p>", source, use_html_safe: true
55
+ end
56
+ end
57
+
58
+ def test_render_splat_with_html_safe_false
59
+ source = %q{
60
+ p *{ title: '&' }
61
+ }
62
+
63
+ with_html_safe do
64
+ assert_html "<p title=\"&amp;\"></p>", source, use_html_safe: true
65
+ end
66
+ end
67
+
68
+ def test_render_splat_injecting_evil_attr_name
69
+ source = %q{
70
+ p *{ "><script>alert(1)</script><p title" => 'test' }
71
+ }
72
+
73
+ with_html_safe do
74
+ assert_raises Slim::InvalidAttributeNameError do
75
+ render(source, use_html_safe: true)
76
+ end
77
+ end
78
+ end
79
+
80
+
81
+ def test_render_attribute_with_html_safe_true
82
+ source = %q{
83
+ p title=('&amp;'.html_safe)
84
+ }
85
+
86
+ with_html_safe do
87
+ assert_html "<p title=\"&amp;\"></p>", source, use_html_safe: true
88
+ end
89
+ end
90
+
91
+ def test_render_with_disable_escape_false
92
+ source = %q{
93
+ = "<p>Hello</p>"
94
+ == "<p>World</p>"
95
+ }
96
+
97
+ assert_html "&lt;p&gt;Hello&lt;/p&gt;<p>World</p>", source
98
+ end
99
+
100
+ def test_render_with_disable_escape_true
101
+ source = %q{
102
+ = "<p>Hello</p>"
103
+ == "<p>World</p>"
104
+ }
105
+
106
+ assert_html "<p>Hello</p><p>World</p>", source, disable_escape: true
107
+ end
108
+
109
+ def test_escaping_evil_method_with_pretty
110
+ source = %q{
111
+ p = evil_method
112
+ }
113
+
114
+ assert_html "<p>\n &lt;script&gt;do_something_evil();&lt;/script&gt;\n</p>", source, pretty: true
115
+ end
116
+
117
+ def test_render_without_html_safe_with_pretty
118
+ source = %q{
119
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
120
+ }
121
+
122
+ assert_html "<p>\n &lt;strong&gt;Hello World\n , meet \&quot;Slim\&quot;&lt;/strong&gt;.\n</p>", source, pretty: true
123
+ end
124
+
125
+ def test_render_with_html_safe_false_with_pretty
126
+ source = %q{
127
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>."
128
+ }
129
+
130
+ with_html_safe do
131
+ assert_html "<p>\n &lt;strong&gt;Hello World\n , meet \&quot;Slim\&quot;&lt;/strong&gt;.\n</p>", source, use_html_safe: true, pretty: true
132
+ end
133
+ end
134
+
135
+ def test_render_with_html_safe_true_with_pretty
136
+ source = %q{
137
+ p = "<strong>Hello World\\n, meet \\"Slim\\"</strong>.".html_safe
138
+ }
139
+
140
+ with_html_safe do
141
+ assert_html "<p>\n <strong>Hello World\n , meet \"Slim\"</strong>.\n</p>", source, use_html_safe: true, pretty: true
142
+ end
143
+ end
144
+
145
+ def test_render_with_disable_escape_false_with_pretty
146
+ source = %q{
147
+ = "<p>Hello</p>"
148
+ == "<p>World</p>"
149
+ }
150
+
151
+ assert_html "&lt;p&gt;Hello&lt;/p&gt;<p>World</p>", source, pretty: true
152
+ end
153
+
154
+ def test_render_with_disable_escape_true_with_pretty
155
+ source = %q{
156
+ = "<p>Hello</p>"
157
+ == "<p>World</p>"
158
+ }
159
+
160
+ assert_html "<p>Hello</p><p>World</p>", source, disable_escape: true, pretty: true
161
+ end
162
+ end
@@ -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