props_template 0.23.0 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -20
- 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 +6 -0
- 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: 4f39427b50eb55be6d32d7e4b2217653cf316161c47cbc8e983cb5db9d2884ef
|
4
|
+
data.tar.gz: 951b23bdd0db81fcd1703d772d471065b79e56ebfb2f4620d68cf35ccd54dfa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b6132b57aae55b5fdaf3b4c8cb64bf80f6b867ab07dda003eca4a20a487fd10a6879e9877486d2fa1c3781ba4c4e38f85ee83406a668cf54b2ebe4335415ce6
|
7
|
+
data.tar.gz: cf2ebd26707c62748c40e646d855251028b8d27e0b3b26ecd1b15ad704ed37740065e3ddbbebeab1f0be0e99ab8b733932e120c521f5eb363fd6dc25be5a5c28
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ json.flash flash.to_h
|
|
31
31
|
json.menu do
|
32
32
|
# By default, all keys will be formatted as camelCase. See #change_key_format
|
33
33
|
|
34
|
-
json.
|
34
|
+
json.currentUser do
|
35
35
|
json.email current_user.email
|
36
36
|
json.avatar current_user.avatar
|
37
37
|
json.inbox current_user.messages.count
|
@@ -40,7 +40,7 @@ end
|
|
40
40
|
|
41
41
|
json.dashboard(defer: :auto) do
|
42
42
|
sleep 5
|
43
|
-
json.
|
43
|
+
json.complexPostMetric 500
|
44
44
|
end
|
45
45
|
|
46
46
|
json.posts do
|
@@ -51,13 +51,13 @@ json.posts do
|
|
51
51
|
json.array! paged_posts, key: :id do |post|
|
52
52
|
json.id post.id
|
53
53
|
json.description post.description
|
54
|
-
json.
|
55
|
-
json.
|
54
|
+
json.commentsCount post.comments.count
|
55
|
+
json.editPath edit_post_path(post)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
json.
|
60
|
-
json.current
|
59
|
+
json.paginationPath posts_path
|
60
|
+
json.current pagedPosts.current_page
|
61
61
|
json.total @posts.count
|
62
62
|
end
|
63
63
|
|
@@ -98,14 +98,14 @@ Defines the attribute or structure. All keys are automatically camelized lower
|
|
98
98
|
by default. See [Change Key Format](#change-key-format) to change this behavior.
|
99
99
|
|
100
100
|
```ruby
|
101
|
-
json.set! :
|
102
|
-
json.set! :
|
101
|
+
json.set! :authorDetails, {...options} do
|
102
|
+
json.set! :firstName, 'David'
|
103
103
|
end
|
104
104
|
|
105
105
|
or
|
106
106
|
|
107
|
-
json.
|
108
|
-
json.
|
107
|
+
json.authorDetails, {...options} do
|
108
|
+
json.firstName 'David'
|
109
109
|
end
|
110
110
|
|
111
111
|
|
@@ -121,11 +121,11 @@ The inline form defines key and value
|
|
121
121
|
|
122
122
|
```ruby
|
123
123
|
|
124
|
-
json.set! :
|
124
|
+
json.set! :firstName, 'David'
|
125
125
|
|
126
126
|
or
|
127
127
|
|
128
|
-
json.
|
128
|
+
json.firstName 'David'
|
129
129
|
|
130
130
|
# => { "firstName": "David" }
|
131
131
|
```
|
@@ -165,7 +165,7 @@ collection = [ {name: 'john'}, {name: 'jim'} ]
|
|
165
165
|
|
166
166
|
json.details do
|
167
167
|
json.array! collection, {...options} do |person|
|
168
|
-
json.
|
168
|
+
json.firstName person[:name]
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -348,7 +348,7 @@ Usage:
|
|
348
348
|
|
349
349
|
```ruby
|
350
350
|
json.author(cache: "some_cache_key") do
|
351
|
-
json.
|
351
|
+
json.firstName "tommy"
|
352
352
|
end
|
353
353
|
|
354
354
|
#or
|
@@ -404,7 +404,7 @@ Usage:
|
|
404
404
|
```ruby
|
405
405
|
json.dashboard(defer: :manual) do
|
406
406
|
sleep 10
|
407
|
-
json.
|
407
|
+
json.someFancyMetric 42
|
408
408
|
end
|
409
409
|
|
410
410
|
|
@@ -412,7 +412,7 @@ end
|
|
412
412
|
|
413
413
|
json.dashboard(defer: [:manual, placeholder: {}]) do
|
414
414
|
sleep 10
|
415
|
-
json.
|
415
|
+
json.someFancyMetric 42
|
416
416
|
end
|
417
417
|
```
|
418
418
|
|
@@ -423,7 +423,7 @@ A auto option is available:
|
|
423
423
|
```ruby
|
424
424
|
json.dashboard(defer: :auto) do
|
425
425
|
sleep 10
|
426
|
-
json.
|
426
|
+
json.someFancyMetric 42
|
427
427
|
end
|
428
428
|
```
|
429
429
|
|
@@ -490,7 +490,7 @@ json.data(search: traversal_path) do
|
|
490
490
|
|
491
491
|
json.personal do
|
492
492
|
json.name 'james'
|
493
|
-
json.
|
493
|
+
json.zipCode 91210
|
494
494
|
end
|
495
495
|
end
|
496
496
|
end
|
@@ -586,8 +586,8 @@ json.flash flash.to_h
|
|
586
586
|
will render Layout first, then the template when `yield json` is used.
|
587
587
|
|
588
588
|
## Change key format
|
589
|
-
By default,
|
590
|
-
|
589
|
+
By default, keys are not formatted. If you want to change this behavior,
|
590
|
+
override it in an initializer:
|
591
591
|
|
592
592
|
```ruby
|
593
593
|
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,6 +10,12 @@ module Props
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def render_props_template(view, template, path, locals)
|
13
|
+
view.instance_eval <<~RUBY, __FILE__, __LINE__ + 1
|
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
|
13
19
|
layout_locals = locals.dup
|
14
20
|
layout_locals[:virtual_path_of_template] = template.virtual_path
|
15
21
|
|
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.30.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-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|