props_template 0.24.0 → 0.31.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 +20 -22
- data/lib/props_template/base.rb +0 -1
- data/lib/props_template/base_with_extensions.rb +1 -4
- data/lib/props_template/layout_patch.rb +2 -11
- data/lib/props_template/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70f4fab3905ff69848d013d7c338bdcd2c83d87a946e6a23dc28ef1361bb69bf
|
4
|
+
data.tar.gz: 441cea11b9c19da3e2179771f7e6df2d370e79e7888955f4401daae96b4088a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a61229bdb5f3c4e61a66a508b371a3e3d74ddffd0091b03b1bed47ba34d36f5e2a7d128fc8e8980fab992f2c784dce670687af72ab9c75af58a5e590898daac9
|
7
|
+
data.tar.gz: 1fdda8df4b8c30f41b3ce5c4537c90f129f7ef7ee853fffa4e3b8dc5afbfdbc64ebf9017ec332ad66d863fd16b5cd16fcaf44431aeb1315793ceb6b5490d349d
|
data/README.md
CHANGED
@@ -29,9 +29,7 @@ conveniences and magic.
|
|
29
29
|
json.flash flash.to_h
|
30
30
|
|
31
31
|
json.menu do
|
32
|
-
|
33
|
-
|
34
|
-
json.current_user do
|
32
|
+
json.currentUser do
|
35
33
|
json.email current_user.email
|
36
34
|
json.avatar current_user.avatar
|
37
35
|
json.inbox current_user.messages.count
|
@@ -40,7 +38,7 @@ end
|
|
40
38
|
|
41
39
|
json.dashboard(defer: :auto) do
|
42
40
|
sleep 5
|
43
|
-
json.
|
41
|
+
json.complexPostMetric 500
|
44
42
|
end
|
45
43
|
|
46
44
|
json.posts do
|
@@ -51,13 +49,13 @@ json.posts do
|
|
51
49
|
json.array! paged_posts, key: :id do |post|
|
52
50
|
json.id post.id
|
53
51
|
json.description post.description
|
54
|
-
json.
|
55
|
-
json.
|
52
|
+
json.commentsCount post.comments.count
|
53
|
+
json.editPath edit_post_path(post)
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
59
|
-
json.
|
60
|
-
json.current
|
57
|
+
json.paginationPath posts_path
|
58
|
+
json.current pagedPosts.current_page
|
61
59
|
json.total @posts.count
|
62
60
|
end
|
63
61
|
|
@@ -98,14 +96,14 @@ Defines the attribute or structure. All keys are automatically camelized lower
|
|
98
96
|
by default. See [Change Key Format](#change-key-format) to change this behavior.
|
99
97
|
|
100
98
|
```ruby
|
101
|
-
json.set! :
|
102
|
-
json.set! :
|
99
|
+
json.set! :authorDetails, {...options} do
|
100
|
+
json.set! :firstName, 'David'
|
103
101
|
end
|
104
102
|
|
105
103
|
or
|
106
104
|
|
107
|
-
json.
|
108
|
-
json.
|
105
|
+
json.authorDetails, {...options} do
|
106
|
+
json.firstName 'David'
|
109
107
|
end
|
110
108
|
|
111
109
|
|
@@ -121,11 +119,11 @@ The inline form defines key and value
|
|
121
119
|
|
122
120
|
```ruby
|
123
121
|
|
124
|
-
json.set! :
|
122
|
+
json.set! :firstName, 'David'
|
125
123
|
|
126
124
|
or
|
127
125
|
|
128
|
-
json.
|
126
|
+
json.firstName 'David'
|
129
127
|
|
130
128
|
# => { "firstName": "David" }
|
131
129
|
```
|
@@ -165,7 +163,7 @@ collection = [ {name: 'john'}, {name: 'jim'} ]
|
|
165
163
|
|
166
164
|
json.details do
|
167
165
|
json.array! collection, {...options} do |person|
|
168
|
-
json.
|
166
|
+
json.firstName person[:name]
|
169
167
|
end
|
170
168
|
end
|
171
169
|
|
@@ -348,7 +346,7 @@ Usage:
|
|
348
346
|
|
349
347
|
```ruby
|
350
348
|
json.author(cache: "some_cache_key") do
|
351
|
-
json.
|
349
|
+
json.firstName "tommy"
|
352
350
|
end
|
353
351
|
|
354
352
|
#or
|
@@ -404,7 +402,7 @@ Usage:
|
|
404
402
|
```ruby
|
405
403
|
json.dashboard(defer: :manual) do
|
406
404
|
sleep 10
|
407
|
-
json.
|
405
|
+
json.someFancyMetric 42
|
408
406
|
end
|
409
407
|
|
410
408
|
|
@@ -412,7 +410,7 @@ end
|
|
412
410
|
|
413
411
|
json.dashboard(defer: [:manual, placeholder: {}]) do
|
414
412
|
sleep 10
|
415
|
-
json.
|
413
|
+
json.someFancyMetric 42
|
416
414
|
end
|
417
415
|
```
|
418
416
|
|
@@ -423,7 +421,7 @@ A auto option is available:
|
|
423
421
|
```ruby
|
424
422
|
json.dashboard(defer: :auto) do
|
425
423
|
sleep 10
|
426
|
-
json.
|
424
|
+
json.someFancyMetric 42
|
427
425
|
end
|
428
426
|
```
|
429
427
|
|
@@ -490,7 +488,7 @@ json.data(search: traversal_path) do
|
|
490
488
|
|
491
489
|
json.personal do
|
492
490
|
json.name 'james'
|
493
|
-
json.
|
491
|
+
json.zipCode 91210
|
494
492
|
end
|
495
493
|
end
|
496
494
|
end
|
@@ -586,8 +584,8 @@ json.flash flash.to_h
|
|
586
584
|
will render Layout first, then the template when `yield json` is used.
|
587
585
|
|
588
586
|
## Change key format
|
589
|
-
By default,
|
590
|
-
|
587
|
+
By default, keys are not formatted. If you want to change this behavior,
|
588
|
+
override it in an initializer:
|
591
589
|
|
592
590
|
```ruby
|
593
591
|
Props::BaseWithExtensions.class_eval do
|
data/lib/props_template/base.rb
CHANGED
@@ -5,10 +5,8 @@ module Props
|
|
5
5
|
def initialize(builder, context = nil, options = {})
|
6
6
|
@context = context
|
7
7
|
@builder = builder
|
8
|
-
# todo: refactor so deferred can be its own class
|
9
8
|
@em = ExtensionManager.new(self)
|
10
9
|
@traveled_path = []
|
11
|
-
@key_cache = {}
|
12
10
|
super()
|
13
11
|
end
|
14
12
|
|
@@ -45,8 +43,7 @@ module Props
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def format_key(key)
|
48
|
-
|
49
|
-
@key_cache[key].dup
|
46
|
+
key.to_s
|
50
47
|
end
|
51
48
|
|
52
49
|
def set!(key, options = {}, &block)
|
@@ -10,18 +10,9 @@ module Props
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def render_props_template(view, template, path, locals)
|
13
|
-
|
14
|
-
def virtual_path_of_template;"#{template.virtual_path}";end
|
15
|
-
RUBY
|
16
|
-
|
17
|
-
# Deprecated: Usage of virtual_path_of_template in local_assigns will
|
18
|
-
# be removed for a method definition above
|
19
|
-
layout_locals = locals.dup
|
20
|
-
layout_locals[:virtual_path_of_template] = template.virtual_path
|
21
|
-
|
22
|
-
layout = resolve_layout(path, layout_locals.keys, [formats.first])
|
13
|
+
layout = resolve_layout(path, locals.keys, [formats.first])
|
23
14
|
body = if layout
|
24
|
-
layout.render(view,
|
15
|
+
layout.render(view, locals) do |json|
|
25
16
|
template.render(view, locals)
|
26
17
|
end
|
27
18
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: props_template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|