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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb11a454a1e500ed9621d34fbe8de5ace212f85997e182ca77c934f42d2ae27e
4
- data.tar.gz: 037ae1fa177ff7c6e50d80ae46a963f70dec15b028c4a46941401c3f4489dfed
3
+ metadata.gz: 4f39427b50eb55be6d32d7e4b2217653cf316161c47cbc8e983cb5db9d2884ef
4
+ data.tar.gz: 951b23bdd0db81fcd1703d772d471065b79e56ebfb2f4620d68cf35ccd54dfa8
5
5
  SHA512:
6
- metadata.gz: acb7e89f553db08953ee7544590dae0c516f21fe4943a6012d77c0c63d865e98fd4926dfda597f3cf17d128f04fa163269dc6e046d884bc24d4f52bd28333758
7
- data.tar.gz: 5a7262526a5dbc19c28ec7235f72ec557acd9a95ba27fcf955a7d6beb08107ec6ea999cbb9e0d247de7b3640cfe94e41b6523059ae6748da3283feca10b005dc
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.current_user do
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.complex_post_metric 500
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.comments_count post.comments.count
55
- json.edit_path edit_post_path(post)
54
+ json.commentsCount post.comments.count
55
+ json.editPath edit_post_path(post)
56
56
  end
57
57
  end
58
58
 
59
- json.pagination_path posts_path
60
- json.current paged_posts.current_page
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! :author_details, {...options} do
102
- json.set! :first_name, 'David'
101
+ json.set! :authorDetails, {...options} do
102
+ json.set! :firstName, 'David'
103
103
  end
104
104
 
105
105
  or
106
106
 
107
- json.author_details, {...options} do
108
- json.first_name 'David'
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! :first_name, 'David'
124
+ json.set! :firstName, 'David'
125
125
 
126
126
  or
127
127
 
128
- json.first_name 'David'
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.first_name person[:name]
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.first_name "tommy"
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.some_fancy_metric 42
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.some_fancy_metric 42
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.some_fancy_metric 42
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.zip_code 91210
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, all keys will be formatted with `camelized(:lower)`. If you want to
590
- change this behavior, override it in an initializer:
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
@@ -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,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
 
@@ -1,3 +1,3 @@
1
1
  module Props
2
- VERSION = "0.23.0".freeze
2
+ VERSION = "0.30.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.23.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-06-30 00:00:00.000000000 Z
11
+ date: 2023-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport