curlybars 1.8.0 → 1.10.0
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 +4 -4
- data/lib/curlybars/error/lex.rb +1 -1
- data/lib/curlybars/error/parse.rb +1 -1
- data/lib/curlybars/node/path.rb +11 -13
- data/lib/curlybars/presenter.rb +2 -2
- data/lib/curlybars/rendering_support.rb +2 -1
- data/lib/curlybars/template_handler.rb +3 -15
- data/lib/curlybars/version.rb +1 -1
- metadata +32 -108
- data/spec/acceptance/application_layout_spec.rb +0 -60
- data/spec/acceptance/collection_blocks_spec.rb +0 -28
- data/spec/acceptance/global_helper_spec.rb +0 -25
- data/spec/curlybars/configuration_spec.rb +0 -57
- data/spec/curlybars/error/base_spec.rb +0 -41
- data/spec/curlybars/error/compile_spec.rb +0 -19
- data/spec/curlybars/error/lex_spec.rb +0 -25
- data/spec/curlybars/error/parse_spec.rb +0 -74
- data/spec/curlybars/error/render_spec.rb +0 -19
- data/spec/curlybars/error/validate_spec.rb +0 -19
- data/spec/curlybars/lexer_spec.rb +0 -490
- data/spec/curlybars/method_whitelist_spec.rb +0 -299
- data/spec/curlybars/processor/tilde_spec.rb +0 -60
- data/spec/curlybars/rendering_support_spec.rb +0 -421
- data/spec/curlybars/safe_buffer_spec.rb +0 -46
- data/spec/curlybars/template_handler_spec.rb +0 -225
- data/spec/integration/cache_spec.rb +0 -126
- data/spec/integration/comment_spec.rb +0 -60
- data/spec/integration/exception_spec.rb +0 -31
- data/spec/integration/node/block_helper_else_spec.rb +0 -420
- data/spec/integration/node/each_else_spec.rb +0 -408
- data/spec/integration/node/each_spec.rb +0 -289
- data/spec/integration/node/escape_spec.rb +0 -27
- data/spec/integration/node/helper_spec.rb +0 -186
- data/spec/integration/node/if_else_spec.rb +0 -170
- data/spec/integration/node/if_spec.rb +0 -153
- data/spec/integration/node/output_spec.rb +0 -66
- data/spec/integration/node/partial_spec.rb +0 -64
- data/spec/integration/node/path_spec.rb +0 -296
- data/spec/integration/node/root_spec.rb +0 -13
- data/spec/integration/node/sub_expression_spec.rb +0 -426
- data/spec/integration/node/template_spec.rb +0 -84
- data/spec/integration/node/unless_else_spec.rb +0 -139
- data/spec/integration/node/unless_spec.rb +0 -128
- data/spec/integration/node/with_spec.rb +0 -178
- data/spec/integration/processor/tilde_spec.rb +0 -38
- data/spec/integration/processors_spec.rb +0 -29
- data/spec/integration/visitor_spec.rb +0 -154
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a21d1b2f9bc23315fd45fc0f3e1f1dba730d7d7555b221968956635e00f2f989
|
|
4
|
+
data.tar.gz: d834d004783806af09cec7fa411bd5184529a30b1d60995cebcba564d54cd5e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '066406790ee118acfcd150c5d604e41298dfca0436be419482e05a71253396827c2314313036dfe03d853a01e2b615fec66ab26fa43058fbd94fa27160dad970'
|
|
7
|
+
data.tar.gz: 21580e1338a0200d0210e298752030320c38fbf7a9f1021912ee638d5b4a3492bfdae79e64eb754f919fb34d17f88c74f624e5aaab577bf566dcaf31ef173188
|
data/lib/curlybars/error/lex.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Curlybars
|
|
|
9
9
|
|
|
10
10
|
error_line = source.split("\n")[line_number - 1]
|
|
11
11
|
before_error = error_line.first(line_offset).last(10)
|
|
12
|
-
after_error = error_line[line_offset + 1
|
|
12
|
+
after_error = error_line[line_offset + 1..].first(10)
|
|
13
13
|
error = error_line[line_offset]
|
|
14
14
|
|
|
15
15
|
details = [before_error, error, after_error]
|
|
@@ -16,7 +16,7 @@ module Curlybars
|
|
|
16
16
|
|
|
17
17
|
error_line = source.split("\n")[line_number - 1]
|
|
18
18
|
before_error = error_line.first(line_offset).last(10)
|
|
19
|
-
after_error = error_line[line_offset + length
|
|
19
|
+
after_error = error_line[line_offset + length..].first(10)
|
|
20
20
|
error = error_line.slice(line_offset, length)
|
|
21
21
|
|
|
22
22
|
details = [before_error, error, after_error]
|
data/lib/curlybars/node/path.rb
CHANGED
|
@@ -109,20 +109,18 @@ module Curlybars
|
|
|
109
109
|
|
|
110
110
|
offset_adjustment = 0
|
|
111
111
|
dotted_path_side.split(/\./).map(&:to_sym).inject(base_tree) do |sub_tree, step|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
raise Curlybars::Error::Validate.new('unallowed_path', message, position, offset_adjustment, path: path, step: step)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
sub_tree[step]
|
|
123
|
-
ensure
|
|
124
|
-
offset_adjustment += step.length + 1 # '1' is the length of the dot
|
|
112
|
+
if step == :this
|
|
113
|
+
next sub_tree
|
|
114
|
+
elsif step == :length && (sub_tree.is_a?(Array) && sub_tree.first.is_a?(Hash))
|
|
115
|
+
next nil # :length is synthesised leaf
|
|
116
|
+
elsif !(sub_tree.is_a?(Hash) && sub_tree.key?(step))
|
|
117
|
+
message = step.to_s == path ? "'#{path}' does not exist" : "not possible to access `#{step}` in `#{path}`"
|
|
118
|
+
raise Curlybars::Error::Validate.new('unallowed_path', message, position, offset_adjustment, path: path, step: step)
|
|
125
119
|
end
|
|
120
|
+
|
|
121
|
+
sub_tree[step]
|
|
122
|
+
ensure
|
|
123
|
+
offset_adjustment += step.length + 1 # '1' is the length of the dot
|
|
126
124
|
end
|
|
127
125
|
end
|
|
128
126
|
end
|
data/lib/curlybars/presenter.rb
CHANGED
|
@@ -276,8 +276,8 @@ module Curlybars
|
|
|
276
276
|
# Delegates private method calls to the current view context.
|
|
277
277
|
#
|
|
278
278
|
# The view context, an instance of ActionView::Base, is set by Rails.
|
|
279
|
-
def method_missing(method, *args, &block)
|
|
280
|
-
@_context.public_send(method, *args, &block)
|
|
279
|
+
def method_missing(method, *args, **kwargs, &block)
|
|
280
|
+
@_context.public_send(method, *args, **kwargs, &block)
|
|
281
281
|
end
|
|
282
282
|
|
|
283
283
|
# Tells ruby (and developers) what methods we can accept.
|
|
@@ -13,17 +13,9 @@ module Curlybars
|
|
|
13
13
|
# template - The ActionView::Template template that should be compiled.
|
|
14
14
|
#
|
|
15
15
|
# Returns a String containing the Ruby code representing the template.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
compile_for_actionview5(template)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
else
|
|
23
|
-
def call(template, source)
|
|
24
|
-
instrument(template) do
|
|
25
|
-
compile(template, source)
|
|
26
|
-
end
|
|
16
|
+
def call(template, source)
|
|
17
|
+
instrument(template) do
|
|
18
|
+
compile(template, source)
|
|
27
19
|
end
|
|
28
20
|
end
|
|
29
21
|
|
|
@@ -51,10 +43,6 @@ module Curlybars
|
|
|
51
43
|
|
|
52
44
|
private
|
|
53
45
|
|
|
54
|
-
def compile_for_actionview5(template)
|
|
55
|
-
compile(template, template.source)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
46
|
def compile(template, source)
|
|
59
47
|
# Template is empty, so there's no need to initialize a presenter.
|
|
60
48
|
return %("") if source.empty?
|
data/lib/curlybars/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: curlybars
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Libo Cannici
|
|
@@ -12,10 +12,10 @@ authors:
|
|
|
12
12
|
- Andreas Garnæs
|
|
13
13
|
- Augusto Silva
|
|
14
14
|
- Attila Večerek
|
|
15
|
-
autorequire:
|
|
15
|
+
autorequire:
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
|
-
date:
|
|
18
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: actionpack
|
|
@@ -23,40 +23,40 @@ dependencies:
|
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '6.0'
|
|
27
27
|
- - "<"
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '7.
|
|
29
|
+
version: '7.2'
|
|
30
30
|
type: :runtime
|
|
31
31
|
prerelease: false
|
|
32
32
|
version_requirements: !ruby/object:Gem::Requirement
|
|
33
33
|
requirements:
|
|
34
34
|
- - ">="
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '
|
|
36
|
+
version: '6.0'
|
|
37
37
|
- - "<"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '7.
|
|
39
|
+
version: '7.2'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: activesupport
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
46
|
+
version: '6.0'
|
|
47
47
|
- - "<"
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '7.
|
|
49
|
+
version: '7.2'
|
|
50
50
|
type: :runtime
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - ">="
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '
|
|
56
|
+
version: '6.0'
|
|
57
57
|
- - "<"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '7.
|
|
59
|
+
version: '7.2'
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
61
|
name: ffi
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -119,20 +119,20 @@ dependencies:
|
|
|
119
119
|
requirements:
|
|
120
120
|
- - ">="
|
|
121
121
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: '
|
|
122
|
+
version: '6.0'
|
|
123
123
|
- - "<"
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: '7.
|
|
125
|
+
version: '7.2'
|
|
126
126
|
type: :development
|
|
127
127
|
prerelease: false
|
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
|
130
130
|
- - ">="
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
|
-
version: '
|
|
132
|
+
version: '6.0'
|
|
133
133
|
- - "<"
|
|
134
134
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: '7.
|
|
135
|
+
version: '7.2'
|
|
136
136
|
- !ruby/object:Gem::Dependency
|
|
137
137
|
name: rake
|
|
138
138
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,72 +151,72 @@ dependencies:
|
|
|
151
151
|
name: rspec-rails
|
|
152
152
|
requirement: !ruby/object:Gem::Requirement
|
|
153
153
|
requirements:
|
|
154
|
-
- - "
|
|
154
|
+
- - ">="
|
|
155
155
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: '
|
|
156
|
+
version: '0'
|
|
157
157
|
type: :development
|
|
158
158
|
prerelease: false
|
|
159
159
|
version_requirements: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements:
|
|
161
|
-
- - "
|
|
161
|
+
- - ">="
|
|
162
162
|
- !ruby/object:Gem::Version
|
|
163
|
-
version: '
|
|
163
|
+
version: '0'
|
|
164
164
|
- !ruby/object:Gem::Dependency
|
|
165
165
|
name: rubocop
|
|
166
166
|
requirement: !ruby/object:Gem::Requirement
|
|
167
167
|
requirements:
|
|
168
168
|
- - "~>"
|
|
169
169
|
- !ruby/object:Gem::Version
|
|
170
|
-
version: 1.
|
|
170
|
+
version: '1.57'
|
|
171
171
|
type: :development
|
|
172
172
|
prerelease: false
|
|
173
173
|
version_requirements: !ruby/object:Gem::Requirement
|
|
174
174
|
requirements:
|
|
175
175
|
- - "~>"
|
|
176
176
|
- !ruby/object:Gem::Version
|
|
177
|
-
version: 1.
|
|
177
|
+
version: '1.57'
|
|
178
178
|
- !ruby/object:Gem::Dependency
|
|
179
179
|
name: rubocop-performance
|
|
180
180
|
requirement: !ruby/object:Gem::Requirement
|
|
181
181
|
requirements:
|
|
182
182
|
- - "~>"
|
|
183
183
|
- !ruby/object:Gem::Version
|
|
184
|
-
version: 1.
|
|
184
|
+
version: '1.19'
|
|
185
185
|
type: :development
|
|
186
186
|
prerelease: false
|
|
187
187
|
version_requirements: !ruby/object:Gem::Requirement
|
|
188
188
|
requirements:
|
|
189
189
|
- - "~>"
|
|
190
190
|
- !ruby/object:Gem::Version
|
|
191
|
-
version: 1.
|
|
191
|
+
version: '1.19'
|
|
192
192
|
- !ruby/object:Gem::Dependency
|
|
193
193
|
name: rubocop-rake
|
|
194
194
|
requirement: !ruby/object:Gem::Requirement
|
|
195
195
|
requirements:
|
|
196
196
|
- - "~>"
|
|
197
197
|
- !ruby/object:Gem::Version
|
|
198
|
-
version: 0.
|
|
198
|
+
version: '0.6'
|
|
199
199
|
type: :development
|
|
200
200
|
prerelease: false
|
|
201
201
|
version_requirements: !ruby/object:Gem::Requirement
|
|
202
202
|
requirements:
|
|
203
203
|
- - "~>"
|
|
204
204
|
- !ruby/object:Gem::Version
|
|
205
|
-
version: 0.
|
|
205
|
+
version: '0.6'
|
|
206
206
|
- !ruby/object:Gem::Dependency
|
|
207
207
|
name: rubocop-rspec
|
|
208
208
|
requirement: !ruby/object:Gem::Requirement
|
|
209
209
|
requirements:
|
|
210
210
|
- - "~>"
|
|
211
211
|
- !ruby/object:Gem::Version
|
|
212
|
-
version: 2.
|
|
212
|
+
version: '2.25'
|
|
213
213
|
type: :development
|
|
214
214
|
prerelease: false
|
|
215
215
|
version_requirements: !ruby/object:Gem::Requirement
|
|
216
216
|
requirements:
|
|
217
217
|
- - "~>"
|
|
218
218
|
- !ruby/object:Gem::Version
|
|
219
|
-
version: 2.
|
|
219
|
+
version: '2.25'
|
|
220
220
|
description: |-
|
|
221
221
|
A view layer for your Rails apps that separates structure and logic, using Handlebars templates.
|
|
222
222
|
Strongly inspired by Curly Template gem by Daniel Schierbeck.
|
|
@@ -267,49 +267,11 @@ files:
|
|
|
267
267
|
- lib/curlybars/template_handler.rb
|
|
268
268
|
- lib/curlybars/version.rb
|
|
269
269
|
- lib/curlybars/visitor.rb
|
|
270
|
-
- spec/acceptance/application_layout_spec.rb
|
|
271
|
-
- spec/acceptance/collection_blocks_spec.rb
|
|
272
|
-
- spec/acceptance/global_helper_spec.rb
|
|
273
|
-
- spec/curlybars/configuration_spec.rb
|
|
274
|
-
- spec/curlybars/error/base_spec.rb
|
|
275
|
-
- spec/curlybars/error/compile_spec.rb
|
|
276
|
-
- spec/curlybars/error/lex_spec.rb
|
|
277
|
-
- spec/curlybars/error/parse_spec.rb
|
|
278
|
-
- spec/curlybars/error/render_spec.rb
|
|
279
|
-
- spec/curlybars/error/validate_spec.rb
|
|
280
|
-
- spec/curlybars/lexer_spec.rb
|
|
281
|
-
- spec/curlybars/method_whitelist_spec.rb
|
|
282
|
-
- spec/curlybars/processor/tilde_spec.rb
|
|
283
|
-
- spec/curlybars/rendering_support_spec.rb
|
|
284
|
-
- spec/curlybars/safe_buffer_spec.rb
|
|
285
|
-
- spec/curlybars/template_handler_spec.rb
|
|
286
|
-
- spec/integration/cache_spec.rb
|
|
287
|
-
- spec/integration/comment_spec.rb
|
|
288
|
-
- spec/integration/exception_spec.rb
|
|
289
|
-
- spec/integration/node/block_helper_else_spec.rb
|
|
290
|
-
- spec/integration/node/each_else_spec.rb
|
|
291
|
-
- spec/integration/node/each_spec.rb
|
|
292
|
-
- spec/integration/node/escape_spec.rb
|
|
293
|
-
- spec/integration/node/helper_spec.rb
|
|
294
|
-
- spec/integration/node/if_else_spec.rb
|
|
295
|
-
- spec/integration/node/if_spec.rb
|
|
296
|
-
- spec/integration/node/output_spec.rb
|
|
297
|
-
- spec/integration/node/partial_spec.rb
|
|
298
|
-
- spec/integration/node/path_spec.rb
|
|
299
|
-
- spec/integration/node/root_spec.rb
|
|
300
|
-
- spec/integration/node/sub_expression_spec.rb
|
|
301
|
-
- spec/integration/node/template_spec.rb
|
|
302
|
-
- spec/integration/node/unless_else_spec.rb
|
|
303
|
-
- spec/integration/node/unless_spec.rb
|
|
304
|
-
- spec/integration/node/with_spec.rb
|
|
305
|
-
- spec/integration/processor/tilde_spec.rb
|
|
306
|
-
- spec/integration/processors_spec.rb
|
|
307
|
-
- spec/integration/visitor_spec.rb
|
|
308
270
|
homepage: https://github.com/zendesk/curlybars
|
|
309
271
|
licenses:
|
|
310
272
|
- Apache-2.0
|
|
311
273
|
metadata: {}
|
|
312
|
-
post_install_message:
|
|
274
|
+
post_install_message:
|
|
313
275
|
rdoc_options:
|
|
314
276
|
- "--charset=UTF-8"
|
|
315
277
|
require_paths:
|
|
@@ -318,53 +280,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
318
280
|
requirements:
|
|
319
281
|
- - ">="
|
|
320
282
|
- !ruby/object:Gem::Version
|
|
321
|
-
version: '
|
|
283
|
+
version: '3.0'
|
|
322
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
323
285
|
requirements:
|
|
324
286
|
- - ">="
|
|
325
287
|
- !ruby/object:Gem::Version
|
|
326
288
|
version: '0'
|
|
327
289
|
requirements: []
|
|
328
|
-
rubygems_version: 3.
|
|
329
|
-
signing_key:
|
|
290
|
+
rubygems_version: 3.5.3
|
|
291
|
+
signing_key:
|
|
330
292
|
specification_version: 4
|
|
331
293
|
summary: Create your views using Handlebars templates!
|
|
332
|
-
test_files:
|
|
333
|
-
- spec/curlybars/rendering_support_spec.rb
|
|
334
|
-
- spec/curlybars/method_whitelist_spec.rb
|
|
335
|
-
- spec/curlybars/configuration_spec.rb
|
|
336
|
-
- spec/curlybars/processor/tilde_spec.rb
|
|
337
|
-
- spec/curlybars/template_handler_spec.rb
|
|
338
|
-
- spec/curlybars/error/compile_spec.rb
|
|
339
|
-
- spec/curlybars/error/render_spec.rb
|
|
340
|
-
- spec/curlybars/error/parse_spec.rb
|
|
341
|
-
- spec/curlybars/error/validate_spec.rb
|
|
342
|
-
- spec/curlybars/error/lex_spec.rb
|
|
343
|
-
- spec/curlybars/error/base_spec.rb
|
|
344
|
-
- spec/curlybars/safe_buffer_spec.rb
|
|
345
|
-
- spec/curlybars/lexer_spec.rb
|
|
346
|
-
- spec/integration/processor/tilde_spec.rb
|
|
347
|
-
- spec/integration/exception_spec.rb
|
|
348
|
-
- spec/integration/processors_spec.rb
|
|
349
|
-
- spec/integration/visitor_spec.rb
|
|
350
|
-
- spec/integration/node/escape_spec.rb
|
|
351
|
-
- spec/integration/node/unless_else_spec.rb
|
|
352
|
-
- spec/integration/node/output_spec.rb
|
|
353
|
-
- spec/integration/node/if_spec.rb
|
|
354
|
-
- spec/integration/node/sub_expression_spec.rb
|
|
355
|
-
- spec/integration/node/unless_spec.rb
|
|
356
|
-
- spec/integration/node/with_spec.rb
|
|
357
|
-
- spec/integration/node/partial_spec.rb
|
|
358
|
-
- spec/integration/node/block_helper_else_spec.rb
|
|
359
|
-
- spec/integration/node/root_spec.rb
|
|
360
|
-
- spec/integration/node/template_spec.rb
|
|
361
|
-
- spec/integration/node/each_spec.rb
|
|
362
|
-
- spec/integration/node/each_else_spec.rb
|
|
363
|
-
- spec/integration/node/helper_spec.rb
|
|
364
|
-
- spec/integration/node/path_spec.rb
|
|
365
|
-
- spec/integration/node/if_else_spec.rb
|
|
366
|
-
- spec/integration/comment_spec.rb
|
|
367
|
-
- spec/integration/cache_spec.rb
|
|
368
|
-
- spec/acceptance/collection_blocks_spec.rb
|
|
369
|
-
- spec/acceptance/global_helper_spec.rb
|
|
370
|
-
- spec/acceptance/application_layout_spec.rb
|
|
294
|
+
test_files: []
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
describe "Using Curlybars for the application layout", type: :request do
|
|
2
|
-
example "A simple layout view in Curlybars" do
|
|
3
|
-
get '/'
|
|
4
|
-
|
|
5
|
-
expect(body).to eq(<<~HTML)
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<title>Dummy app</title>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<h1>Dashboard</h1>
|
|
12
|
-
<p>Hello, World!</p>
|
|
13
|
-
<p>Welcome!</p>
|
|
14
|
-
|
|
15
|
-
</body>
|
|
16
|
-
</html>
|
|
17
|
-
HTML
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe "Curlybars" do
|
|
21
|
-
before do
|
|
22
|
-
Curlybars.configure do |config|
|
|
23
|
-
config.presenters_namespace = 'curlybars_presenters'
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
after do
|
|
28
|
-
Curlybars.reset
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
example "A simple layout view in Curlybars with html safe logic" do
|
|
32
|
-
get '/articles/1'
|
|
33
|
-
|
|
34
|
-
expect(body).to eq(<<~HTML)
|
|
35
|
-
<html>
|
|
36
|
-
<head>
|
|
37
|
-
<title>Dummy app</title>
|
|
38
|
-
</head>
|
|
39
|
-
<body>
|
|
40
|
-
<p>Hi Admin</p>
|
|
41
|
-
|
|
42
|
-
<h1>Article: The Prince</h1>
|
|
43
|
-
|
|
44
|
-
<p>This is <strong>important</strong>!</p>
|
|
45
|
-
|
|
46
|
-
<p><script>alert('bad')</script></p>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<p>
|
|
50
|
-
author Nicolò
|
|
51
|
-
<img src="http://example.com/foo.png" />
|
|
52
|
-
</p>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
</body>
|
|
56
|
-
</html>
|
|
57
|
-
HTML
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
describe "Collection blocks", type: :request do
|
|
2
|
-
before do
|
|
3
|
-
Curlybars.configure do |config|
|
|
4
|
-
config.presenters_namespace = 'curlybars_presenters'
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
example "Rendering collections" do
|
|
9
|
-
get '/categories'
|
|
10
|
-
|
|
11
|
-
expect(body).to eq(<<~HTML)
|
|
12
|
-
<html>
|
|
13
|
-
<head>
|
|
14
|
-
<title>Dummy app</title>
|
|
15
|
-
</head>
|
|
16
|
-
<body>
|
|
17
|
-
|
|
18
|
-
<h1>This are the categories</h1>
|
|
19
|
-
|
|
20
|
-
<p>One</p>
|
|
21
|
-
<p>Two</p>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
</body>
|
|
25
|
-
</html>
|
|
26
|
-
HTML
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
describe "Collection blocks", type: :request do
|
|
2
|
-
before do
|
|
3
|
-
Curlybars.configure do |config|
|
|
4
|
-
config.presenters_namespace = 'curlybars_presenters'
|
|
5
|
-
config.global_helpers_provider_classes = [GlobalHelpers]
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
example "Render a global helper" do
|
|
10
|
-
get '/welcome'
|
|
11
|
-
|
|
12
|
-
expect(body).to eq(<<~HTML)
|
|
13
|
-
<html>
|
|
14
|
-
<head>
|
|
15
|
-
<title>Dummy app</title>
|
|
16
|
-
</head>
|
|
17
|
-
<body>
|
|
18
|
-
Login as: Admin
|
|
19
|
-
Account: Testing
|
|
20
|
-
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
23
|
-
HTML
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
describe Curlybars::Configuration do
|
|
2
|
-
after do
|
|
3
|
-
Curlybars.reset
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
describe "#presenters_namespace" do
|
|
7
|
-
it "defaults to an empty string" do
|
|
8
|
-
presenters_namespace = Curlybars::Configuration.new.presenters_namespace
|
|
9
|
-
|
|
10
|
-
expect(presenters_namespace).to eq('')
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "#presenters_namespace=" do
|
|
15
|
-
it "can set value" do
|
|
16
|
-
config = Curlybars::Configuration.new
|
|
17
|
-
config.presenters_namespace = 'foo'
|
|
18
|
-
expect(config.presenters_namespace).to eq('foo')
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
describe "#custom_processors" do
|
|
23
|
-
it "can set value" do
|
|
24
|
-
config = Curlybars::Configuration.new
|
|
25
|
-
config.custom_processors = ['test']
|
|
26
|
-
expect(config.custom_processors).to eq(['test'])
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe ".configure" do
|
|
31
|
-
before do
|
|
32
|
-
Curlybars.configure do |config|
|
|
33
|
-
config.presenters_namespace = 'bar'
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "returns correct value for presenters_namespace" do
|
|
38
|
-
presenters_namespace = Curlybars.configuration.presenters_namespace
|
|
39
|
-
|
|
40
|
-
expect(presenters_namespace).to eq('bar')
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
describe ".reset" do
|
|
45
|
-
it "resets the configuration to default value" do
|
|
46
|
-
Curlybars.configure do |config|
|
|
47
|
-
config.presenters_namespace = 'foobarbaz'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
Curlybars.reset
|
|
51
|
-
|
|
52
|
-
presenters_namespace = Curlybars.configuration.presenters_namespace
|
|
53
|
-
|
|
54
|
-
expect(presenters_namespace).to eq('')
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
describe Curlybars::Error::Base do
|
|
2
|
-
let(:position) do
|
|
3
|
-
OpenStruct.new(line_number: 1, line_offset: 0)
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
it "creates an exception with the given message" do
|
|
7
|
-
message = "message"
|
|
8
|
-
|
|
9
|
-
exception = Curlybars::Error::Base.new('id', message, position)
|
|
10
|
-
|
|
11
|
-
expect(exception.message).to be message
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "doesn't change the backtrace for nil position.file_name" do
|
|
15
|
-
exception = Curlybars::Error::Base.new('id', 'message', position)
|
|
16
|
-
|
|
17
|
-
expect(exception.backtrace).to be nil
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "sets the right backtrace for non-nil position.file_name" do
|
|
21
|
-
position.file_name = 'template.hbs'
|
|
22
|
-
|
|
23
|
-
exception = Curlybars::Error::Base.new('id', 'message', position)
|
|
24
|
-
|
|
25
|
-
expect(exception.backtrace).not_to be nil
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "sets the position as an instance varaible" do
|
|
29
|
-
exception = Curlybars::Error::Base.new('id', 'message', position)
|
|
30
|
-
|
|
31
|
-
expect(exception.position).to be position
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "sets the id as an instance varaible" do
|
|
35
|
-
id = 'id'
|
|
36
|
-
|
|
37
|
-
exception = Curlybars::Error::Base.new(id, 'message', position)
|
|
38
|
-
|
|
39
|
-
expect(exception.id).to be id
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
describe Curlybars::Error::Compile do
|
|
2
|
-
let(:position) do
|
|
3
|
-
OpenStruct.new(
|
|
4
|
-
line_number: 2,
|
|
5
|
-
line_offset: 3,
|
|
6
|
-
stream_offset: 14,
|
|
7
|
-
length: 3,
|
|
8
|
-
file_name: 'template.hbs'
|
|
9
|
-
)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "prefixes the id with `compile.`" do
|
|
13
|
-
id = 'id'
|
|
14
|
-
|
|
15
|
-
exception = Curlybars::Error::Compile.new(id, 'message', position)
|
|
16
|
-
|
|
17
|
-
expect(exception.id).to eq 'compile.%s' % id
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
describe Curlybars::Error::Lex do
|
|
2
|
-
let(:file_name) { 'template.hbs' }
|
|
3
|
-
|
|
4
|
-
let(:source) { "first_line\n0123456789\nthird_line" }
|
|
5
|
-
|
|
6
|
-
let(:exception) do
|
|
7
|
-
OpenStruct.new(line_number: 2, line_offset: 2)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "creates an exception with a meaningful message" do
|
|
11
|
-
message = ".. 01 `2` 3456789 .. is not permitted symbol in this context"
|
|
12
|
-
|
|
13
|
-
lex_exception = Curlybars::Error::Lex.new(source, file_name, exception)
|
|
14
|
-
|
|
15
|
-
expect(lex_exception.message).to eq message
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "figures out a position from the exception" do
|
|
19
|
-
backtrace = "%s:%d:%d" % [file_name, exception.line_number, exception.line_offset]
|
|
20
|
-
|
|
21
|
-
lex_exception = Curlybars::Error::Lex.new(source, file_name, exception)
|
|
22
|
-
|
|
23
|
-
expect(lex_exception.backtrace).to eq [backtrace]
|
|
24
|
-
end
|
|
25
|
-
end
|