props_template 0.24.0 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed3fa0a5fda4993c730d2391de3e2a1d7f05e43580dc5e429734b5f8e7b07391
4
- data.tar.gz: 005ed8fa15532e3e80530fae2a4c1bbd0002d9b9dcf5e2a41c64d34c62df2db0
3
+ metadata.gz: 70f4fab3905ff69848d013d7c338bdcd2c83d87a946e6a23dc28ef1361bb69bf
4
+ data.tar.gz: 441cea11b9c19da3e2179771f7e6df2d370e79e7888955f4401daae96b4088a1
5
5
  SHA512:
6
- metadata.gz: 2a65e69050103126e02af67ebbf44af9817edd221467fef1ae6f9c715964b8c212ecc9d3a8796e9ec0868e395911668f11176dae3ce5c722620f9eccb326cede
7
- data.tar.gz: b59b42c55eee9fb209093c38aeab2d369da005a6be41feecd73ecef62f6323b61ac41e879e005b40b584817d80e2b8873fb37c2c62dc22015177053371b5c08f
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
- # By default, all keys will be formatted as camelCase. See #change_key_format
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.complex_post_metric 500
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.comments_count post.comments.count
55
- json.edit_path edit_post_path(post)
52
+ json.commentsCount post.comments.count
53
+ json.editPath edit_post_path(post)
56
54
  end
57
55
  end
58
56
 
59
- json.pagination_path posts_path
60
- json.current paged_posts.current_page
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! :author_details, {...options} do
102
- json.set! :first_name, 'David'
99
+ json.set! :authorDetails, {...options} do
100
+ json.set! :firstName, 'David'
103
101
  end
104
102
 
105
103
  or
106
104
 
107
- json.author_details, {...options} do
108
- json.first_name 'David'
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! :first_name, 'David'
122
+ json.set! :firstName, 'David'
125
123
 
126
124
  or
127
125
 
128
- json.first_name 'David'
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.first_name person[:name]
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.first_name "tommy"
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.some_fancy_metric 42
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.some_fancy_metric 42
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.some_fancy_metric 42
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.zip_code 91210
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, all keys will be formatted with `camelized(:lower)`. If you want to
590
- change this behavior, override it in an initializer:
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
@@ -115,7 +115,6 @@ module Props
115
115
  @stream.reset
116
116
 
117
117
  @scope = nil
118
- @key_cache = {}
119
118
  json
120
119
  end
121
120
  end
@@ -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
- @key_cache[key] ||= key.to_s.camelize(:lower)
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
- 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
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, layout_locals) do |json|
15
+ layout.render(view, locals) do |json|
25
16
  template.render(view, locals)
26
17
  end
27
18
  else
@@ -1,3 +1,3 @@
1
1
  module Props
2
- VERSION = "0.24.0".freeze
2
+ VERSION = "0.31.0".freeze
3
3
  end
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.24.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-04 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport