props_template 0.36.0 → 0.38.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/README.md +37 -37
- data/lib/props_template/base.rb +32 -4
- data/lib/props_template/base_with_extensions.rb +4 -0
- data/lib/props_template/extension_manager.rb +14 -6
- data/lib/props_template/extensions/deferment.rb +6 -1
- data/lib/props_template/extensions/partial_renderer.rb +5 -0
- data/lib/props_template/partial_patch.rb +39 -0
- data/lib/props_template/railtie.rb +1 -0
- data/lib/props_template/searcher.rb +55 -22
- data/lib/props_template/version.rb +1 -1
- data/lib/props_template.rb +8 -2
- metadata +22 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3667a1f94d254d08bf49d419e9c8d9c8fa72a4d5c4b4420c1caf65e3dbbf3e1c
|
4
|
+
data.tar.gz: 2a6bda4d99a4ce0aef62debf10ebbbe75399ea065390b5cd55a6208a9ff0d97b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc2851e095c1a83749d16b8256915ea76a1e1b76e6dd945f893030912b8920a45f6d7c8ee7722a0abd1d8eddf021d4884bdf4b19d74728df25ac85885b333e97
|
7
|
+
data.tar.gz: 3a18ecfd1c477c87e7a7ee267db634bd750c6c6b4a2804478ce850c9e0a633215bc9d33765b4487245d2f4b017e5826830cde72ba54387b53443eb0dcd79b437
|
data/README.md
CHANGED
@@ -72,7 +72,7 @@ gem 'props_template'
|
|
72
72
|
and run `bundle`.
|
73
73
|
|
74
74
|
Optionally add the [core ext](#array-core-extension) to an initializer if you
|
75
|
-
want to [dig](#
|
75
|
+
want to [dig](#digging) into your templates.
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
require 'props_template/core_ext'
|
@@ -100,7 +100,7 @@ json.set! :authorDetails, {...options} do
|
|
100
100
|
json.set! :firstName, 'David'
|
101
101
|
end
|
102
102
|
|
103
|
-
or
|
103
|
+
# or
|
104
104
|
|
105
105
|
json.authorDetails, {...options} do
|
106
106
|
json.firstName 'David'
|
@@ -121,7 +121,7 @@ The inline form defines key and value
|
|
121
121
|
|
122
122
|
json.set! :firstName, 'David'
|
123
123
|
|
124
|
-
or
|
124
|
+
# or
|
125
125
|
|
126
126
|
json.firstName 'David'
|
127
127
|
|
@@ -138,13 +138,13 @@ The block form defines key and structure
|
|
138
138
|
|
139
139
|
```ruby
|
140
140
|
json.set! :details do
|
141
|
-
...
|
141
|
+
# ...
|
142
142
|
end
|
143
143
|
|
144
144
|
or
|
145
145
|
|
146
146
|
json.details do
|
147
|
-
...
|
147
|
+
# ...
|
148
148
|
end
|
149
149
|
```
|
150
150
|
|
@@ -152,7 +152,7 @@ The difference between the block form and inline form is
|
|
152
152
|
1. The block form is an internal node. Functionality such as Partials,
|
153
153
|
Deferment and other [options](#options) are only available on the
|
154
154
|
block form.
|
155
|
-
2. The inline form is considered a leaf node, and you can only [
|
155
|
+
2. The inline form is considered a leaf node, and you can only [dig](#digging)
|
156
156
|
for internal nodes.
|
157
157
|
|
158
158
|
### json.extract!
|
@@ -199,10 +199,10 @@ end
|
|
199
199
|
|
200
200
|
| Parameter | Notes |
|
201
201
|
| :--- | :--- |
|
202
|
-
| collection | A collection that responds to `member_at` and `member_by` |
|
202
|
+
| collection | A collection that optionally responds to `member_at` and `member_by` |
|
203
203
|
| options | Additional [options](#options)|
|
204
204
|
|
205
|
-
To support [
|
205
|
+
To support [digging](#digging), any list passed
|
206
206
|
to `array!` MUST implement `member_at(index)` and `member_by(attr, value)`.
|
207
207
|
|
208
208
|
For example, if you were using a delegate:
|
@@ -230,7 +230,7 @@ data = ObjectCollection.new([
|
|
230
230
|
])
|
231
231
|
|
232
232
|
json.array! data do
|
233
|
-
...
|
233
|
+
# ...
|
234
234
|
end
|
235
235
|
```
|
236
236
|
|
@@ -252,7 +252,7 @@ Then in your template:
|
|
252
252
|
|
253
253
|
```ruby
|
254
254
|
json.array! Post.all do
|
255
|
-
...
|
255
|
+
# ...
|
256
256
|
end
|
257
257
|
```
|
258
258
|
|
@@ -270,13 +270,13 @@ data = [
|
|
270
270
|
|
271
271
|
json.posts
|
272
272
|
json.array! data do
|
273
|
-
...
|
273
|
+
# ...
|
274
274
|
end
|
275
275
|
end
|
276
276
|
```
|
277
277
|
|
278
278
|
PropsTemplate does not know what the elements are in your collection. The
|
279
|
-
example above will be fine for [
|
279
|
+
example above will be fine for [digging](#digging)
|
280
280
|
by index, but will raise a `NotImplementedError` if you query by attribute. You
|
281
281
|
may still need to implement `member_by`.
|
282
282
|
|
@@ -306,7 +306,7 @@ option.
|
|
306
306
|
`application.json.props` when first running `rails superglue:install:web`
|
307
307
|
|
308
308
|
## Options
|
309
|
-
Options Functionality such as Partials,
|
309
|
+
Options Functionality such as Partials, Deferments, and Caching can only be
|
310
310
|
set on a block. It is normal to see empty blocks.
|
311
311
|
|
312
312
|
```ruby
|
@@ -339,7 +339,7 @@ end
|
|
339
339
|
|
340
340
|
Rendering partials without a key is also supported using `json.partial!`, but use
|
341
341
|
sparingly! `json.partial!` is not optimized for collection rendering and may
|
342
|
-
cause performance problems.
|
342
|
+
cause performance problems. It's best used for things like a shared header or footer.
|
343
343
|
|
344
344
|
Do:
|
345
345
|
|
@@ -359,7 +359,7 @@ end
|
|
359
359
|
|
360
360
|
Do NOT:
|
361
361
|
|
362
|
-
```
|
362
|
+
```ruby
|
363
363
|
@post.each do |post|
|
364
364
|
json.partial! partial: "post", locals: {post: @post} do
|
365
365
|
end
|
@@ -406,12 +406,12 @@ json.author(cache: "some_cache_key") do
|
|
406
406
|
json.firstName "tommy"
|
407
407
|
end
|
408
408
|
|
409
|
-
#or
|
409
|
+
# or
|
410
410
|
|
411
411
|
json.profile(cache: "cachekey", partial: ["profile", locals: {foo: 1}]) do
|
412
412
|
end
|
413
413
|
|
414
|
-
#or nest it
|
414
|
+
# or nest it
|
415
415
|
|
416
416
|
json.author(cache: "some_cache_key") do
|
417
417
|
json.address(cache: "some_other_cache_key") do
|
@@ -431,7 +431,7 @@ json.array! [4,5], opts do |x|
|
|
431
431
|
json.top "hello" + x.to_s
|
432
432
|
end
|
433
433
|
|
434
|
-
#or on arrays with partials
|
434
|
+
# or on arrays with partials
|
435
435
|
|
436
436
|
opts = { cache: (->(d){ ['a', d.id] }), partial: ["blog_post", as: :blog_post] }
|
437
437
|
|
@@ -447,9 +447,9 @@ entirely and replace the value with a placeholder. A common use case would be
|
|
447
447
|
tabbed content that does not load until you click the tab.
|
448
448
|
|
449
449
|
When your client receives the payload, you may issue a second request to the
|
450
|
-
same endpoint to fetch any missing nodes. See [
|
450
|
+
same endpoint to fetch any missing nodes. See [digging](#digging)
|
451
451
|
|
452
|
-
There is also
|
452
|
+
There is also a `defer: :auto` option that you can use with [SuperglueJS][1]. [SuperglueJS][1]
|
453
453
|
will use the metadata from `json.deferred!` to issue a `remote` dispatch to fetch
|
454
454
|
the missing node and immutably graft it at the appropriate keypath in your Redux
|
455
455
|
store.
|
@@ -489,10 +489,10 @@ json.defers json.deferred!
|
|
489
489
|
```
|
490
490
|
|
491
491
|
#### Working with arrays
|
492
|
-
The default behavior for
|
492
|
+
The default behavior for deferments is to use the index of the collection to
|
493
493
|
identify an element.
|
494
494
|
|
495
|
-
**Note** If you are using this library with [SuperglueJS][1], the `:auto`
|
495
|
+
**Note** If you are using this library with [SuperglueJS][1], the `:auto` option will
|
496
496
|
generate `?props_at=a.b.c.0.title` for `json.deferred!`.
|
497
497
|
|
498
498
|
If you wish to use an attribute to identify the element. You must:
|
@@ -502,7 +502,7 @@ your collection item, and is used for `defer: :auto` to generate a keypath for
|
|
502
502
|
[SuperglueJS][1]. If you are NOT using SuperglueJS, you do not need to do this.
|
503
503
|
|
504
504
|
2. Implement `member_at`, on the [collection](#jsonarray). This will be called
|
505
|
-
by PropsTemplate to when [
|
505
|
+
by PropsTemplate to when [digging](#digging)
|
506
506
|
|
507
507
|
For example:
|
508
508
|
|
@@ -525,10 +525,10 @@ json.posts
|
|
525
525
|
end
|
526
526
|
```
|
527
527
|
|
528
|
-
If you are using [SuperglueJS][1],
|
528
|
+
If you are using [SuperglueJS][1], it will automatically kick off
|
529
529
|
`remote(?props_at=posts.some_id=1.contact)` and `remote(?props_at=posts.some_id=2.contact)`.
|
530
530
|
|
531
|
-
##
|
531
|
+
## Digging
|
532
532
|
|
533
533
|
PropsTemplate has the ability to walk the tree you build, skipping execution of
|
534
534
|
untargeted nodes. This feature is useful for selectively updating your frontend
|
@@ -537,10 +537,10 @@ state.
|
|
537
537
|
```ruby
|
538
538
|
traversal_path = ['data', 'details', 'personal']
|
539
539
|
|
540
|
-
json.data(
|
540
|
+
json.data(dig: traversal_path) do
|
541
541
|
json.details do
|
542
542
|
json.employment do
|
543
|
-
...more stuff
|
543
|
+
# ...more stuff
|
544
544
|
end
|
545
545
|
|
546
546
|
json.personal do
|
@@ -551,12 +551,12 @@ json.data(search: traversal_path) do
|
|
551
551
|
end
|
552
552
|
|
553
553
|
json.footer do
|
554
|
-
...
|
554
|
+
# ...
|
555
555
|
end
|
556
556
|
```
|
557
557
|
|
558
558
|
PropsTemplate will walk depth first, walking only when it finds a matching key,
|
559
|
-
then executes the associated block, and repeats until
|
559
|
+
then executes the associated block, and repeats until the node is found.
|
560
560
|
The above will output:
|
561
561
|
|
562
562
|
```json
|
@@ -571,13 +571,13 @@ The above will output:
|
|
571
571
|
}
|
572
572
|
```
|
573
573
|
|
574
|
-
|
574
|
+
Digging only works with blocks, and will NOT work with Scalars
|
575
575
|
("leaf" values). For example:
|
576
576
|
|
577
577
|
```ruby
|
578
|
-
traversal_path = ['data', 'details', 'personal', 'name'] <- not found
|
578
|
+
traversal_path = ['data', 'details', 'personal', 'name'] # <- not found
|
579
579
|
|
580
|
-
json.data(
|
580
|
+
json.data(dig: traversal_path) do
|
581
581
|
json.details do
|
582
582
|
json.personal do
|
583
583
|
json.name 'james'
|
@@ -588,12 +588,12 @@ end
|
|
588
588
|
|
589
589
|
## Nodes that do not exist
|
590
590
|
|
591
|
-
Nodes that are not found will remove the branch where
|
591
|
+
Nodes that are not found will remove the branch where digging was enabled on.
|
592
592
|
|
593
593
|
```ruby
|
594
594
|
traversal_path = ['data', 'details', 'does_not_exist']
|
595
595
|
|
596
|
-
json.data(
|
596
|
+
json.data(dig: traversal_path) do
|
597
597
|
json.details do
|
598
598
|
json.personal do
|
599
599
|
json.name 'james'
|
@@ -602,7 +602,7 @@ json.data(search: traversal_path) do
|
|
602
602
|
end
|
603
603
|
|
604
604
|
json.footer do
|
605
|
-
...
|
605
|
+
# ...
|
606
606
|
end
|
607
607
|
```
|
608
608
|
|
@@ -641,8 +641,8 @@ json.flash flash.to_h
|
|
641
641
|
will render Layout first, then the template when `yield json` is used.
|
642
642
|
|
643
643
|
## Change key format
|
644
|
-
By default, keys are not formatted. This is intentional. By being
|
645
|
-
it makes your views quicker and more easily
|
644
|
+
By default, keys are not formatted. This is intentional. By being explicit with your keys,
|
645
|
+
it makes your views quicker and more easily diggable when working in JavaScript land.
|
646
646
|
|
647
647
|
If you must change this behavior, override it in an initializer and cache the value:
|
648
648
|
|
data/lib/props_template/base.rb
CHANGED
@@ -6,6 +6,8 @@ module Props
|
|
6
6
|
|
7
7
|
class InvalidScopeForObjError < StandardError; end
|
8
8
|
|
9
|
+
class InvalidScopeForChildError < StandardError; end
|
10
|
+
|
9
11
|
class Base
|
10
12
|
def initialize(encoder = nil)
|
11
13
|
@stream = Oj::StringWriter.new(mode: :rails)
|
@@ -87,8 +89,7 @@ module Props
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
|
-
|
91
|
-
def array!(collection, options = {})
|
92
|
+
def array!(collection = nil, options = {})
|
92
93
|
if @scope.nil?
|
93
94
|
@scope = :array
|
94
95
|
@stream.push_array
|
@@ -96,8 +97,13 @@ module Props
|
|
96
97
|
raise InvalidScopeForArrayError.new("array! expects exclusive use of this block")
|
97
98
|
end
|
98
99
|
|
99
|
-
|
100
|
-
|
100
|
+
if collection.nil?
|
101
|
+
@child_index = nil
|
102
|
+
yield
|
103
|
+
else
|
104
|
+
handle_collection(collection, options) do |item, index|
|
105
|
+
yield item, index
|
106
|
+
end
|
101
107
|
end
|
102
108
|
|
103
109
|
@scope = :array
|
@@ -131,6 +137,28 @@ module Props
|
|
131
137
|
end
|
132
138
|
end
|
133
139
|
|
140
|
+
def child!(options = {})
|
141
|
+
if @scope != :array
|
142
|
+
raise InvalidScopeForChildError.new("child! can only be used in a `array!` with no arguments")
|
143
|
+
end
|
144
|
+
|
145
|
+
if !block_given?
|
146
|
+
raise ArgumentError.new("child! requires a block")
|
147
|
+
end
|
148
|
+
|
149
|
+
inner_scope = @scope
|
150
|
+
child_index = @child_index || -1
|
151
|
+
child_index += 1
|
152
|
+
|
153
|
+
# this changes the scope to nil so child in a child will break
|
154
|
+
set_block_content!(options) do
|
155
|
+
yield
|
156
|
+
end
|
157
|
+
|
158
|
+
@scope = inner_scope
|
159
|
+
@child_index = child_index
|
160
|
+
end
|
161
|
+
|
134
162
|
def result!
|
135
163
|
if @scope.nil?
|
136
164
|
@stream.push_object
|
@@ -12,9 +12,16 @@ module Props
|
|
12
12
|
@cache = Cache.new(@context)
|
13
13
|
end
|
14
14
|
|
15
|
+
def disable_deferments
|
16
|
+
@deferment.disable!
|
17
|
+
end
|
18
|
+
|
15
19
|
def refine_options(options, item = nil)
|
16
20
|
options = @partialer.refine_options(options, item)
|
17
|
-
|
21
|
+
if !@deferment.disabled
|
22
|
+
options = @deferment.refine_options(options, item)
|
23
|
+
end
|
24
|
+
|
18
25
|
Cache.refine_options(options, item)
|
19
26
|
end
|
20
27
|
|
@@ -40,7 +47,7 @@ module Props
|
|
40
47
|
def handle(options)
|
41
48
|
return yield if !has_extensions(options)
|
42
49
|
|
43
|
-
if options[:defer]
|
50
|
+
if options[:defer] && !@deferment.disabled
|
44
51
|
placeholder = @deferment.handle(options)
|
45
52
|
base.stream.push_value(placeholder)
|
46
53
|
@fragment.handle(options)
|
@@ -86,12 +93,13 @@ module Props
|
|
86
93
|
result
|
87
94
|
end
|
88
95
|
|
96
|
+
meta, raw_json = state.split("\n")
|
97
|
+
next_deferred, next_fragments = Oj.load(meta)
|
98
|
+
deferred.push(*next_deferred)
|
99
|
+
fragments.push(*next_fragments)
|
100
|
+
|
89
101
|
if !recently_cached
|
90
|
-
meta, raw_json = state.split("\n")
|
91
|
-
next_deferred, next_fragments = Oj.load(meta)
|
92
102
|
base.stream.push_json(raw_json)
|
93
|
-
deferred.push(*next_deferred)
|
94
|
-
fragments.push(*next_fragments)
|
95
103
|
end
|
96
104
|
else
|
97
105
|
yield
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module Props
|
2
2
|
class Deferment
|
3
|
-
attr_reader :deferred
|
3
|
+
attr_reader :deferred, :disabled
|
4
4
|
|
5
5
|
def initialize(base, deferred = [])
|
6
6
|
@deferred = deferred
|
7
7
|
@base = base
|
8
|
+
@disabled = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def disable!
|
12
|
+
@disabled = true
|
8
13
|
end
|
9
14
|
|
10
15
|
def refine_options(options, item = nil)
|
@@ -152,6 +152,10 @@ module Props
|
|
152
152
|
locals[as] = item
|
153
153
|
|
154
154
|
if (fragment_name = rest[:fragment])
|
155
|
+
if item && ::Proc === fragment_name
|
156
|
+
fragment_name = fragment_name.call(item)
|
157
|
+
end
|
158
|
+
|
155
159
|
rest[:fragment] = fragment_name.to_s
|
156
160
|
end
|
157
161
|
end
|
@@ -163,3 +167,4 @@ module Props
|
|
163
167
|
end
|
164
168
|
end
|
165
169
|
end
|
170
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Props
|
2
|
+
module PartialPatch
|
3
|
+
def render(partial, context, block)
|
4
|
+
template = find_template(partial, template_keys(partial))
|
5
|
+
|
6
|
+
if !block && (layout = @options[:layout])
|
7
|
+
layout = find_template(layout.to_s, template_keys(partial))
|
8
|
+
end
|
9
|
+
|
10
|
+
if template.respond_to?(:handler) && template.handler == Props::Handler && layout
|
11
|
+
render_partial_props_template(context, @locals, template, layout, block)
|
12
|
+
else
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def render_partial_props_template(view, locals, template, layout, block)
|
18
|
+
ActiveSupport::Notifications.instrument(
|
19
|
+
"render_partial.action_view",
|
20
|
+
identifier: template.identifier,
|
21
|
+
layout: layout && layout.virtual_path,
|
22
|
+
locals: locals
|
23
|
+
) do |payload|
|
24
|
+
body = if layout
|
25
|
+
layout.render(view, locals, add_to_stack: !block) do |json|
|
26
|
+
template.render(view, locals)
|
27
|
+
end
|
28
|
+
else
|
29
|
+
template.render(view, locals)
|
30
|
+
end
|
31
|
+
|
32
|
+
build_rendered_template(body, template)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
ActionView::PartialRenderer.prepend(Props::PartialPatch)
|
39
|
+
|
@@ -60,42 +60,75 @@ module Props
|
|
60
60
|
nil
|
61
61
|
end
|
62
62
|
|
63
|
-
def array!(collection, options = {}, &block)
|
63
|
+
def array!(collection = nil, options = {}, &block)
|
64
64
|
return if @found_block
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
id_val = id_val.to_i
|
71
|
-
item = collection.member_by(id_name, id_val)
|
66
|
+
if collection.nil?
|
67
|
+
# Handle child! mode - initialize child_index for searching
|
68
|
+
@child_index = nil
|
69
|
+
yield
|
72
70
|
else
|
73
|
-
|
74
|
-
|
71
|
+
# Original collection handling
|
72
|
+
key_index = @search_path[@depth]
|
73
|
+
id_name, id_val = key_index.to_s.split("=")
|
74
|
+
|
75
|
+
if id_val
|
76
|
+
id_val = id_val.to_i
|
77
|
+
item = collection.member_by(id_name, id_val)
|
78
|
+
else
|
79
|
+
index = id_name.to_i
|
80
|
+
item = collection.member_at(index)
|
81
|
+
end
|
82
|
+
|
83
|
+
if item
|
84
|
+
pass_opts = @partialer.refine_options(options, item)
|
85
|
+
@traveled_path.push(key_index)
|
86
|
+
|
87
|
+
if @depth == @search_path.size - 1
|
88
|
+
@found_options = pass_opts
|
89
|
+
@found_block = proc {
|
90
|
+
yield item, 0
|
91
|
+
}
|
92
|
+
return
|
93
|
+
end
|
94
|
+
|
95
|
+
@depth += 1
|
96
|
+
if pass_opts[:partial]
|
97
|
+
# todo: what happens when cached: true is passed?
|
98
|
+
# would there be any problems with not using the collection_rende?
|
99
|
+
@partialer.handle(pass_opts)
|
100
|
+
else
|
101
|
+
yield item, 0
|
102
|
+
end
|
103
|
+
@depth -= 1
|
104
|
+
end
|
75
105
|
end
|
106
|
+
end
|
76
107
|
|
77
|
-
|
78
|
-
|
108
|
+
def child!(options={}, &block)
|
109
|
+
return if @found_block
|
110
|
+
|
111
|
+
child_index = @child_index || -1
|
112
|
+
child_index += 1
|
113
|
+
|
114
|
+
key_index = @search_path[@depth]
|
115
|
+
target_index = key_index.to_i
|
116
|
+
|
117
|
+
if child_index == target_index
|
79
118
|
@traveled_path.push(key_index)
|
80
119
|
|
81
120
|
if @depth == @search_path.size - 1
|
82
|
-
@found_options =
|
83
|
-
@found_block =
|
84
|
-
yield item, 0
|
85
|
-
}
|
121
|
+
@found_options = {}
|
122
|
+
@found_block = block
|
86
123
|
return
|
87
124
|
end
|
88
125
|
|
89
126
|
@depth += 1
|
90
|
-
|
91
|
-
# todo: what happens when cached: true is passed?
|
92
|
-
# would there be any problems with not using the collection_rende?
|
93
|
-
@partialer.handle(pass_opts)
|
94
|
-
else
|
95
|
-
yield item, 0
|
96
|
-
end
|
127
|
+
yield
|
97
128
|
@depth -= 1
|
98
129
|
end
|
130
|
+
|
131
|
+
@child_index = child_index
|
99
132
|
end
|
100
133
|
end
|
101
134
|
end
|
data/lib/props_template.rb
CHANGED
@@ -22,10 +22,12 @@ module Props
|
|
22
22
|
self.template_lookup_options = {handlers: [:props]}
|
23
23
|
|
24
24
|
delegate :result!, :array!,
|
25
|
+
:child!,
|
25
26
|
:partial!,
|
26
27
|
:extract!,
|
27
28
|
:deferred!,
|
28
29
|
:fragments!,
|
30
|
+
:disable_deferments!,
|
29
31
|
:set_block_content!,
|
30
32
|
:traveled_path!,
|
31
33
|
to: :builder!
|
@@ -36,11 +38,15 @@ module Props
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def set!(key, options = {}, &block)
|
39
|
-
if block && options[:search] && !@builder.is_a?(Searcher)
|
41
|
+
if block && (options[:search] || options[:dig]) && !@builder.is_a?(Searcher)
|
42
|
+
search = options[:search] || options[:dig]
|
40
43
|
|
41
44
|
prev_builder = @builder
|
42
|
-
@builder = Searcher.new(self,
|
45
|
+
@builder = Searcher.new(self, search, @context)
|
46
|
+
|
43
47
|
options.delete(:search)
|
48
|
+
options.delete(:dig)
|
49
|
+
|
44
50
|
@builder.set!(key, options, &block)
|
45
51
|
found_block, found_options = @builder.found!
|
46
52
|
@builder = prev_builder
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: props_template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.38.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-07-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -16,40 +15,52 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
18
|
+
version: '7.0'
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '9.0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
23
25
|
requirements:
|
24
26
|
- - ">="
|
25
27
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
28
|
+
version: '7.0'
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '9.0'
|
27
32
|
- !ruby/object:Gem::Dependency
|
28
33
|
name: actionview
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
30
35
|
requirements:
|
31
36
|
- - ">="
|
32
37
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
38
|
+
version: '7.0'
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '9.0'
|
34
42
|
type: :runtime
|
35
43
|
prerelease: false
|
36
44
|
version_requirements: !ruby/object:Gem::Requirement
|
37
45
|
requirements:
|
38
46
|
- - ">="
|
39
47
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
48
|
+
version: '7.0'
|
49
|
+
- - "<"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '9.0'
|
41
52
|
- !ruby/object:Gem::Dependency
|
42
53
|
name: oj
|
43
54
|
requirement: !ruby/object:Gem::Requirement
|
44
55
|
requirements:
|
45
|
-
- - "
|
56
|
+
- - "~>"
|
46
57
|
- !ruby/object:Gem::Version
|
47
58
|
version: '3.9'
|
48
59
|
type: :runtime
|
49
60
|
prerelease: false
|
50
61
|
version_requirements: !ruby/object:Gem::Requirement
|
51
62
|
requirements:
|
52
|
-
- - "
|
63
|
+
- - "~>"
|
53
64
|
- !ruby/object:Gem::Version
|
54
65
|
version: '3.9'
|
55
66
|
description: PropsTemplate is a direct-to-Oj, JBuilder-like DSL for building JSON.
|
@@ -73,6 +84,7 @@ files:
|
|
73
84
|
- lib/props_template/extensions/partial_renderer.rb
|
74
85
|
- lib/props_template/handler.rb
|
75
86
|
- lib/props_template/layout_patch.rb
|
87
|
+
- lib/props_template/partial_patch.rb
|
76
88
|
- lib/props_template/railtie.rb
|
77
89
|
- lib/props_template/searcher.rb
|
78
90
|
- lib/props_template/version.rb
|
@@ -80,7 +92,6 @@ homepage: https://github.com/thoughtbot/props_template/
|
|
80
92
|
licenses:
|
81
93
|
- MIT
|
82
94
|
metadata: {}
|
83
|
-
post_install_message:
|
84
95
|
rdoc_options: []
|
85
96
|
require_paths:
|
86
97
|
- lib
|
@@ -95,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
106
|
- !ruby/object:Gem::Version
|
96
107
|
version: '0'
|
97
108
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
99
|
-
signing_key:
|
109
|
+
rubygems_version: 3.6.2
|
100
110
|
specification_version: 4
|
101
111
|
summary: A fast JSON builder
|
102
112
|
test_files: []
|