slim 1.3.0 → 1.3.2
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.
- data/.travis.yml +9 -5
- data/CHANGES +23 -0
- data/Gemfile +13 -2
- data/README.md +346 -105
- data/Rakefile +21 -9
- data/lib/slim.rb +3 -3
- data/lib/slim/boolean_attributes.rb +67 -0
- data/lib/slim/command.rb +23 -23
- data/lib/slim/control_structures.rb +57 -0
- data/lib/slim/embedded_engine.rb +80 -43
- data/lib/slim/end_inserter.rb +1 -1
- data/lib/slim/engine.rb +21 -15
- data/lib/slim/filter.rb +0 -6
- data/lib/slim/grammar.rb +2 -7
- data/lib/slim/interpolation.rb +1 -1
- data/lib/slim/logic_less/filter.rb +8 -8
- data/lib/slim/logic_less/wrapper.rb +1 -1
- data/lib/slim/parser.rb +51 -52
- data/lib/slim/splat_attributes.rb +112 -0
- data/lib/slim/translator.rb +13 -12
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +1 -1
- data/test/{slim → core}/helper.rb +3 -7
- data/test/{slim → core}/test_code_blocks.rb +0 -0
- data/test/{slim → core}/test_code_escaping.rb +4 -4
- data/test/{slim → core}/test_code_evaluation.rb +3 -112
- data/test/{slim → core}/test_code_output.rb +0 -0
- data/test/{slim → core}/test_code_structure.rb +0 -0
- data/test/{slim → core}/test_embedded_engines.rb +8 -3
- data/test/{slim → core}/test_encoding.rb +0 -0
- data/test/core/test_html_attributes.rb +218 -0
- data/test/{slim → core}/test_html_escaping.rb +17 -0
- data/test/{slim → core}/test_html_structure.rb +13 -98
- data/test/{slim → core}/test_parser_errors.rb +24 -15
- data/test/{slim → core}/test_pretty.rb +0 -0
- data/test/{slim → core}/test_ruby_errors.rb +7 -0
- data/test/{slim → core}/test_slim_template.rb +0 -0
- data/test/{slim → core}/test_text_interpolation.rb +2 -2
- data/test/core/test_thread_options.rb +18 -0
- data/test/{slim/logic_less → logic_less}/test_logic_less.rb +21 -0
- data/test/{slim/logic_less → logic_less}/test_wrapper.rb +3 -3
- data/test/rails/app/controllers/slim_controller.rb +4 -2
- data/test/rails/app/views/parents/_form.html.slim +1 -0
- data/test/rails/app/views/parents/edit.html.slim +2 -1
- data/test/rails/app/views/parents/new.html.slim +2 -1
- data/test/rails/app/views/slim/thread_options.html.slim +1 -0
- data/test/rails/test/test_slim.rb +6 -4
- data/test/{slim/translator → translator}/test_translator.rb +0 -0
- metadata +44 -82
- data/lib/slim/compiler.rb +0 -194
- data/test/rails/app/views/slim/nil.html.slim +0 -1
- data/test/slim/test_chain_manipulation.rb +0 -42
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,27 +11,22 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: temple
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirement: &18956260 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.5.0
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ~>
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: 0.4.1
|
26
|
+
version_requirements: *18956260
|
32
27
|
- !ruby/object:Gem::Dependency
|
33
28
|
name: tilt
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirement: &18955320 !ruby/object:Gem::Requirement
|
35
30
|
none: false
|
36
31
|
requirements:
|
37
32
|
- - ~>
|
@@ -39,15 +34,10 @@ dependencies:
|
|
39
34
|
version: 1.3.3
|
40
35
|
type: :runtime
|
41
36
|
prerelease: false
|
42
|
-
version_requirements:
|
43
|
-
none: false
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.3.3
|
37
|
+
version_requirements: *18955320
|
48
38
|
- !ruby/object:Gem::Dependency
|
49
39
|
name: rake
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirement: &18970580 !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
42
|
requirements:
|
53
43
|
- - ! '>='
|
@@ -55,15 +45,10 @@ dependencies:
|
|
55
45
|
version: 0.8.7
|
56
46
|
type: :development
|
57
47
|
prerelease: false
|
58
|
-
version_requirements:
|
59
|
-
none: false
|
60
|
-
requirements:
|
61
|
-
- - ! '>='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 0.8.7
|
48
|
+
version_requirements: *18970580
|
64
49
|
- !ruby/object:Gem::Dependency
|
65
50
|
name: sass
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirement: &18970100 !ruby/object:Gem::Requirement
|
67
52
|
none: false
|
68
53
|
requirements:
|
69
54
|
- - ! '>='
|
@@ -71,15 +56,10 @@ dependencies:
|
|
71
56
|
version: 3.1.0
|
72
57
|
type: :development
|
73
58
|
prerelease: false
|
74
|
-
version_requirements:
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ! '>='
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: 3.1.0
|
59
|
+
version_requirements: *18970100
|
80
60
|
- !ruby/object:Gem::Dependency
|
81
61
|
name: minitest
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirement: &18969540 !ruby/object:Gem::Requirement
|
83
63
|
none: false
|
84
64
|
requirements:
|
85
65
|
- - ! '>='
|
@@ -87,15 +67,10 @@ dependencies:
|
|
87
67
|
version: '0'
|
88
68
|
type: :development
|
89
69
|
prerelease: false
|
90
|
-
version_requirements:
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ! '>='
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0'
|
70
|
+
version_requirements: *18969540
|
96
71
|
- !ruby/object:Gem::Dependency
|
97
72
|
name: kramdown
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirement: &18968820 !ruby/object:Gem::Requirement
|
99
74
|
none: false
|
100
75
|
requirements:
|
101
76
|
- - ! '>='
|
@@ -103,15 +78,10 @@ dependencies:
|
|
103
78
|
version: '0'
|
104
79
|
type: :development
|
105
80
|
prerelease: false
|
106
|
-
version_requirements:
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ! '>='
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version: '0'
|
81
|
+
version_requirements: *18968820
|
112
82
|
- !ruby/object:Gem::Dependency
|
113
83
|
name: creole
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirement: &18967940 !ruby/object:Gem::Requirement
|
115
85
|
none: false
|
116
86
|
requirements:
|
117
87
|
- - ! '>='
|
@@ -119,15 +89,10 @@ dependencies:
|
|
119
89
|
version: '0'
|
120
90
|
type: :development
|
121
91
|
prerelease: false
|
122
|
-
version_requirements:
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- - ! '>='
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '0'
|
92
|
+
version_requirements: *18967940
|
128
93
|
- !ruby/object:Gem::Dependency
|
129
94
|
name: builder
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
95
|
+
requirement: &18966900 !ruby/object:Gem::Requirement
|
131
96
|
none: false
|
132
97
|
requirements:
|
133
98
|
- - ! '>='
|
@@ -135,12 +100,7 @@ dependencies:
|
|
135
100
|
version: '0'
|
136
101
|
type: :development
|
137
102
|
prerelease: false
|
138
|
-
version_requirements:
|
139
|
-
none: false
|
140
|
-
requirements:
|
141
|
-
- - ! '>='
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '0'
|
103
|
+
version_requirements: *18966900
|
144
104
|
description: Slim is a template language whose goal is reduce the syntax to the essential
|
145
105
|
parts without becoming cryptic.
|
146
106
|
email:
|
@@ -174,8 +134,9 @@ files:
|
|
174
134
|
- benchmarks/view.slim
|
175
135
|
- bin/slimrb
|
176
136
|
- lib/slim.rb
|
137
|
+
- lib/slim/boolean_attributes.rb
|
177
138
|
- lib/slim/command.rb
|
178
|
-
- lib/slim/
|
139
|
+
- lib/slim/control_structures.rb
|
179
140
|
- lib/slim/embedded_engine.rb
|
180
141
|
- lib/slim/end_inserter.rb
|
181
142
|
- lib/slim/engine.rb
|
@@ -186,10 +147,30 @@ files:
|
|
186
147
|
- lib/slim/logic_less/filter.rb
|
187
148
|
- lib/slim/logic_less/wrapper.rb
|
188
149
|
- lib/slim/parser.rb
|
150
|
+
- lib/slim/splat_attributes.rb
|
189
151
|
- lib/slim/template.rb
|
190
152
|
- lib/slim/translator.rb
|
191
153
|
- lib/slim/version.rb
|
192
154
|
- slim.gemspec
|
155
|
+
- test/core/helper.rb
|
156
|
+
- test/core/test_code_blocks.rb
|
157
|
+
- test/core/test_code_escaping.rb
|
158
|
+
- test/core/test_code_evaluation.rb
|
159
|
+
- test/core/test_code_output.rb
|
160
|
+
- test/core/test_code_structure.rb
|
161
|
+
- test/core/test_embedded_engines.rb
|
162
|
+
- test/core/test_encoding.rb
|
163
|
+
- test/core/test_html_attributes.rb
|
164
|
+
- test/core/test_html_escaping.rb
|
165
|
+
- test/core/test_html_structure.rb
|
166
|
+
- test/core/test_parser_errors.rb
|
167
|
+
- test/core/test_pretty.rb
|
168
|
+
- test/core/test_ruby_errors.rb
|
169
|
+
- test/core/test_slim_template.rb
|
170
|
+
- test/core/test_text_interpolation.rb
|
171
|
+
- test/core/test_thread_options.rb
|
172
|
+
- test/logic_less/test_logic_less.rb
|
173
|
+
- test/logic_less/test_wrapper.rb
|
193
174
|
- test/rails/Rakefile
|
194
175
|
- test/rails/app/controllers/application_controller.rb
|
195
176
|
- test/rails/app/controllers/parents_controller.rb
|
@@ -206,10 +187,10 @@ files:
|
|
206
187
|
- test/rails/app/views/slim/content_for.html.slim
|
207
188
|
- test/rails/app/views/slim/erb.html.erb
|
208
189
|
- test/rails/app/views/slim/integers.html.slim
|
209
|
-
- test/rails/app/views/slim/nil.html.slim
|
210
190
|
- test/rails/app/views/slim/no_layout.html.slim
|
211
191
|
- test/rails/app/views/slim/normal.html.slim
|
212
192
|
- test/rails/app/views/slim/partial.html.slim
|
193
|
+
- test/rails/app/views/slim/thread_options.html.slim
|
213
194
|
- test/rails/app/views/slim/variables.html.slim
|
214
195
|
- test/rails/config.ru
|
215
196
|
- test/rails/config/application.rb
|
@@ -230,25 +211,7 @@ files:
|
|
230
211
|
- test/rails/script/rails
|
231
212
|
- test/rails/test/helper.rb
|
232
213
|
- test/rails/test/test_slim.rb
|
233
|
-
- test/
|
234
|
-
- test/slim/logic_less/test_logic_less.rb
|
235
|
-
- test/slim/logic_less/test_wrapper.rb
|
236
|
-
- test/slim/test_chain_manipulation.rb
|
237
|
-
- test/slim/test_code_blocks.rb
|
238
|
-
- test/slim/test_code_escaping.rb
|
239
|
-
- test/slim/test_code_evaluation.rb
|
240
|
-
- test/slim/test_code_output.rb
|
241
|
-
- test/slim/test_code_structure.rb
|
242
|
-
- test/slim/test_embedded_engines.rb
|
243
|
-
- test/slim/test_encoding.rb
|
244
|
-
- test/slim/test_html_escaping.rb
|
245
|
-
- test/slim/test_html_structure.rb
|
246
|
-
- test/slim/test_parser_errors.rb
|
247
|
-
- test/slim/test_pretty.rb
|
248
|
-
- test/slim/test_ruby_errors.rb
|
249
|
-
- test/slim/test_slim_template.rb
|
250
|
-
- test/slim/test_text_interpolation.rb
|
251
|
-
- test/slim/translator/test_translator.rb
|
214
|
+
- test/translator/test_translator.rb
|
252
215
|
homepage: http://slim-lang.com/
|
253
216
|
licenses: []
|
254
217
|
post_install_message:
|
@@ -270,9 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
233
|
version: '0'
|
271
234
|
requirements: []
|
272
235
|
rubyforge_project: slim
|
273
|
-
rubygems_version: 1.8.
|
236
|
+
rubygems_version: 1.8.15
|
274
237
|
signing_key:
|
275
238
|
specification_version: 3
|
276
239
|
summary: Slim is a template language.
|
277
240
|
test_files: []
|
278
|
-
has_rdoc:
|
data/lib/slim/compiler.rb
DELETED
@@ -1,194 +0,0 @@
|
|
1
|
-
module Slim
|
2
|
-
# @api private
|
3
|
-
class Compiler < Filter
|
4
|
-
def call(exp)
|
5
|
-
@attr_delimiter, @splat_used = unique_name, false
|
6
|
-
exp = compile(exp)
|
7
|
-
if @splat_used
|
8
|
-
[:multi, [:code, "#{@attr_delimiter} = #{@options[:attr_delimiter].inspect}"], exp]
|
9
|
-
else
|
10
|
-
exp
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Handle control expression `[:slim, :control, code, content]`
|
15
|
-
#
|
16
|
-
# @param [String] code Ruby code
|
17
|
-
# @param [Array] content Temple expression
|
18
|
-
# @return [Array] Compiled temple expression
|
19
|
-
def on_slim_control(code, content)
|
20
|
-
[:multi,
|
21
|
-
[:code, code],
|
22
|
-
compile(content)]
|
23
|
-
end
|
24
|
-
|
25
|
-
# Handle output expression `[:slim, :output, escape, code, content]`
|
26
|
-
#
|
27
|
-
# @param [Boolean] escape Escape html
|
28
|
-
# @param [String] code Ruby code
|
29
|
-
# @param [Array] content Temple expression
|
30
|
-
# @return [Array] Compiled temple expression
|
31
|
-
def on_slim_output(escape, code, content)
|
32
|
-
if empty_exp?(content)
|
33
|
-
[:multi, [:escape, escape, [:dynamic, code]], content]
|
34
|
-
else
|
35
|
-
tmp = unique_name
|
36
|
-
|
37
|
-
[:multi,
|
38
|
-
# Capture the result of the code in a variable. We can't do
|
39
|
-
# `[:dynamic, code]` because it's probably not a complete
|
40
|
-
# expression (which is a requirement for Temple).
|
41
|
-
[:block, "#{tmp} = #{code}",
|
42
|
-
|
43
|
-
# Capture the content of a block in a separate buffer. This means
|
44
|
-
# that `yield` will not output the content to the current buffer,
|
45
|
-
# but rather return the output.
|
46
|
-
#
|
47
|
-
# The capturing can be disabled with the option :disable_capture.
|
48
|
-
# Output code in the block writes directly to the output buffer then.
|
49
|
-
# Rails handles this by replacing the output buffer for helpers.
|
50
|
-
options[:disable_capture] ? compile(content) : [:capture, unique_name, compile(content)]],
|
51
|
-
|
52
|
-
# Output the content.
|
53
|
-
[:escape, escape, [:dynamic, tmp]]]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Handle text expression `[:slim, :text, content]`
|
58
|
-
#
|
59
|
-
# @param [Array] content Temple expression
|
60
|
-
# @return [Array] Compiled temple expression
|
61
|
-
def on_slim_text(content)
|
62
|
-
compile(content)
|
63
|
-
end
|
64
|
-
|
65
|
-
# Handle tag expression `[:slim, :tag, name, attrs, content]`
|
66
|
-
#
|
67
|
-
# @param [String] name Tag name
|
68
|
-
# @param [Array] attrs Temple expression
|
69
|
-
# @param [Array] content Temple expression
|
70
|
-
# @return [Array] Compiled temple expression
|
71
|
-
def on_slim_tag(name, attrs, content = nil)
|
72
|
-
if name == '*'
|
73
|
-
hash, merger, formatter = splat_attributes(attrs[2..-1])
|
74
|
-
tmp = unique_name
|
75
|
-
tag = [:multi,
|
76
|
-
merger,
|
77
|
-
[:code, "#{tmp} = #{hash}.delete('tag').to_s"],
|
78
|
-
[:if, "#{tmp}.empty?",
|
79
|
-
[:code, "#{tmp} = #{@options[:default_tag].inspect}"]],
|
80
|
-
[:static, '<'],
|
81
|
-
[:dynamic, "#{tmp}"],
|
82
|
-
formatter]
|
83
|
-
tag << if content
|
84
|
-
[:multi,
|
85
|
-
[:static, '>'],
|
86
|
-
compile(content),
|
87
|
-
[:static, '</'],
|
88
|
-
[:dynamic, "#{tmp}"],
|
89
|
-
[:static, '>']]
|
90
|
-
else
|
91
|
-
[:static, '/>']
|
92
|
-
end
|
93
|
-
else
|
94
|
-
tag = [:html, :tag, name, compile(attrs)]
|
95
|
-
content ? (tag << compile(content)) : tag
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Handle attributes expression `[:slim, :attrs, *attrs]`
|
100
|
-
#
|
101
|
-
# @param [Array] attrs Array of temple expressions
|
102
|
-
# @return [Array] Compiled temple expression
|
103
|
-
def on_slim_attrs(*attrs)
|
104
|
-
if attrs.any? {|attr| attr[1] == :splat}
|
105
|
-
hash, merger, formatter = splat_attributes(attrs)
|
106
|
-
[:multi, merger, formatter]
|
107
|
-
else
|
108
|
-
[:html, :attrs, *attrs.map {|a| compile(a) }]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
# Handle attribute expression `[:slim, :attr, escape, code]`
|
113
|
-
#
|
114
|
-
# @param [Boolean] escape Escape html
|
115
|
-
# @param [String] code Ruby code
|
116
|
-
# @return [Array] Compiled temple expression
|
117
|
-
def on_slim_attr(name, escape, code)
|
118
|
-
value = case code
|
119
|
-
when 'true'
|
120
|
-
[:static, name]
|
121
|
-
when 'false', 'nil'
|
122
|
-
[:multi]
|
123
|
-
else
|
124
|
-
tmp = unique_name
|
125
|
-
[:multi,
|
126
|
-
[:code, "#{tmp} = #{code}"],
|
127
|
-
[:case, tmp,
|
128
|
-
['true', [:static, name]],
|
129
|
-
['false, nil', [:multi]],
|
130
|
-
[:else,
|
131
|
-
[:escape, escape, [:dynamic,
|
132
|
-
if delimiter = options[:attr_delimiter][name]
|
133
|
-
"#{tmp}.respond_to?(:join) ? #{tmp}.flatten.compact.join(#{delimiter.inspect}) : #{tmp}"
|
134
|
-
else
|
135
|
-
tmp
|
136
|
-
end
|
137
|
-
]]]]]
|
138
|
-
end
|
139
|
-
[:html, :attr, name, value]
|
140
|
-
end
|
141
|
-
|
142
|
-
protected
|
143
|
-
|
144
|
-
def splat_attributes(attrs)
|
145
|
-
@splat_used = true
|
146
|
-
|
147
|
-
hash, name, value, tmp = unique_name, unique_name, unique_name, unique_name
|
148
|
-
|
149
|
-
merger = [:multi, [:code, "#{hash} = {}"]]
|
150
|
-
attrs.each do |attr|
|
151
|
-
merger << if attr[0] == :html && attr[1] == :attr
|
152
|
-
[:multi,
|
153
|
-
[:capture, tmp, compile(attr[3])],
|
154
|
-
[:code, "(#{hash}[#{attr[2].inspect}] ||= []) << #{tmp}"]]
|
155
|
-
elsif attr[0] == :slim
|
156
|
-
if attr[1] == :attr
|
157
|
-
[:code, "(#{hash}[#{attr[2].inspect}] ||= []) << (#{attr[4]})"]
|
158
|
-
elsif attr[1] == :splat
|
159
|
-
[:code, "(#{attr[2]}).each {|#{name},#{value}| (#{hash}[#{name}.to_s] ||= []) << (#{value}) }"]
|
160
|
-
else
|
161
|
-
attr
|
162
|
-
end
|
163
|
-
else
|
164
|
-
attr
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
merger << [:block, "#{hash}.keys.each do |#{name}|",
|
169
|
-
[:multi,
|
170
|
-
[:code, "#{value} = #{hash}[#{name}]"],
|
171
|
-
[:code, "#{value}.flatten!"],
|
172
|
-
[:block, "#{value}.map! do |#{tmp}|",
|
173
|
-
[:case, tmp,
|
174
|
-
['true', [:code, name]],
|
175
|
-
['false, nil', [:multi]],
|
176
|
-
[:else, [:code, tmp]]]],
|
177
|
-
[:if, "#{value}.size > 1 && !#{@attr_delimiter}[#{name}]",
|
178
|
-
[:code, "raise(\"Multiple #\{#{name}\} attributes specified\")"]],
|
179
|
-
[:code, "#{hash}[#{name}] = #{value}.compact.join(#{@attr_delimiter}[#{name}].to_s)"]]]
|
180
|
-
|
181
|
-
attr = [:multi,
|
182
|
-
[:static, ' '],
|
183
|
-
[:dynamic, name],
|
184
|
-
[:static, "=#{options[:attr_wrapper]}"],
|
185
|
-
[:escape, true, [:dynamic, value]],
|
186
|
-
[:static, options[:attr_wrapper]]]
|
187
|
-
attr = [:if, "!#{value}.empty?", attr] if options[:remove_empty_attrs]
|
188
|
-
enumerator = options[:sort_attrs] ? "#{hash}.sort_by {|#{name},#{value}| #{name} }" : hash
|
189
|
-
formatter = [:block, "#{enumerator}.each do |#{name},#{value}|", attr]
|
190
|
-
|
191
|
-
return hash, merger, formatter
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
p= @nil
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestSlimChainManipulation < TestSlim
|
4
|
-
def test_replace
|
5
|
-
source = %q{
|
6
|
-
p Test
|
7
|
-
}
|
8
|
-
chain = proc do |engine|
|
9
|
-
engine.replace(:Pretty, :ReplacementFilter) do |exp|
|
10
|
-
[:dynamic, '1+1']
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
assert_html '2', source, :chain => chain
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_before
|
18
|
-
source = %q{
|
19
|
-
p Test
|
20
|
-
}
|
21
|
-
chain = proc do |engine|
|
22
|
-
engine.before(Slim::Parser, :WrapInput) do |input|
|
23
|
-
"p Header\n#{input}\np Footer"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
assert_html '<p>Header</p><p>Test</p><p>Footer</p>', source, :chain => chain
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_after
|
31
|
-
source = %q{
|
32
|
-
p Test
|
33
|
-
}
|
34
|
-
chain = proc do |engine|
|
35
|
-
engine.after(Slim::Parser, :ReplaceParsedExp) do |exp|
|
36
|
-
[:slim, :output, false, '1+1', [:multi]]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
assert_html '2', source, :chain => chain
|
41
|
-
end
|
42
|
-
end
|