wallaby-view 0.1.3 → 0.1.7
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 +47 -12
- data/lib/wallaby/view/action_viewable.rb +18 -13
- data/lib/wallaby/view/custom_lookup_context.rb +2 -2
- data/lib/wallaby/view/custom_prefixes.rb +24 -16
- data/lib/wallaby/view/themeable.rb +20 -23
- data/lib/wallaby/view/version.rb +1 -1
- data/lib/wallaby/view.rb +18 -29
- metadata +52 -10
- data/lib/action_view/partial_renderer.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7144207990b4071d9aa101d8a2bbee5b282264bd896768f5b4a0640d8eba14f
|
4
|
+
data.tar.gz: f8190dfba431bafbf38eb6c23cffb17932c6b223e7d52840c0846ddad2a654b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c44424c02029a37a88a5a7b090befda949dfb72838ff0dd113fa1efdaacc942b12e1aed6c15fcc5c38ec07e3e0fd8f38cc7c197a79b6bb89835714c7d3bb69ca
|
7
|
+
data.tar.gz: 0ed6828b6445a7b9c101a6cd07100d726308536c58e684a2f1d61531c74d62cbb6e0a8d0dd745d66776d4e912f715d8ecd9fdd065b8bbaf317f5acbb2ead712d
|
data/README.md
CHANGED
@@ -7,11 +7,14 @@
|
|
7
7
|
[](https://codeclimate.com/github/wallaby-rails/wallaby-view/test_coverage)
|
8
8
|
[](https://inch-ci.org/github/wallaby-rails/wallaby-view)
|
9
9
|
|
10
|
-
|
10
|
+
**Wallaby::View** extends Rails template/partial inheritance chain to be able to:
|
11
|
+
|
12
|
+
- organize partials in `#{controller_path}/#{action}` fashion on top of Rails' controller fashion by extending Rails' [\_prefixes](https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L90).
|
13
|
+
- configure the theme (a set of layout/templates/partials starting with the theme prefix).
|
11
14
|
|
12
15
|
## Install
|
13
16
|
|
14
|
-
Add
|
17
|
+
Add **Wallaby::View** to `Gemfile`.
|
15
18
|
|
16
19
|
```ruby
|
17
20
|
gem 'wallaby-view'
|
@@ -23,7 +26,7 @@ And re-bundle.
|
|
23
26
|
bundle install
|
24
27
|
```
|
25
28
|
|
26
|
-
Include
|
29
|
+
Include **Wallaby::View** in the controller (e.g. **ApplicationController**):
|
27
30
|
|
28
31
|
```ruby
|
29
32
|
# app/controllers/application_controller
|
@@ -43,18 +46,18 @@ class ApplicationController < ActionController::Base
|
|
43
46
|
end
|
44
47
|
|
45
48
|
# app/controllers/admin/application_controller
|
46
|
-
class Admin::ApplicationController < ApplicationController
|
49
|
+
class Admin::ApplicationController < ::ApplicationController
|
47
50
|
self.theme_name = 'secure'
|
48
51
|
end
|
49
52
|
|
50
53
|
# app/controllers/admin/users_controller
|
51
54
|
class Admin::UsersController < Admin::ApplicationController
|
52
55
|
self.theme_name = 'account'
|
53
|
-
self.
|
56
|
+
self.prefix_options = { edit: 'form' }
|
54
57
|
end
|
55
58
|
```
|
56
59
|
|
57
|
-
By using
|
60
|
+
By using **Wallaby::View**, a template/partial for the `admin/application#edit` action will be looked up in the following folder order from top to bottom:
|
58
61
|
|
59
62
|
- app/views/admin/application/edit
|
60
63
|
- app/views/admin/application
|
@@ -63,31 +66,63 @@ By using `Wallaby::View`, the lookup folder order of `admin/application#edit` ac
|
|
63
66
|
- app/views/application/edit
|
64
67
|
- app/views/application
|
65
68
|
|
66
|
-
Then it
|
69
|
+
Then it depends on how a relative partial should be shared, the partial can be created in one of the above folders.
|
70
|
+
For example, if a `form` partial is designed specifically for `admin/application#edit` action, then it can be created in `admin/application/edit` folder as below:
|
71
|
+
|
72
|
+
```erb
|
73
|
+
<%# app/views/admin/application/edit/_form.html.erb %>
|
74
|
+
a form for `admin/application#edit`
|
75
|
+
```
|
76
|
+
|
77
|
+
Then in the `admin/application#edit` template, rendering the relative `form` partial will result in using the above partial.
|
67
78
|
|
68
79
|
```erb
|
69
80
|
<%# app/views/admin/application/edit.html.erb %>
|
70
81
|
<% render 'form' %>
|
71
|
-
|
72
|
-
<%# app/views/secure/edit/_form.html.erb %>
|
73
|
-
This form partial is under `secure` theme and `edit` action,
|
74
|
-
but still can be rendered by `admin/application#edit` action
|
75
82
|
```
|
76
83
|
|
77
|
-
For `admin/users#edit` action, since `
|
84
|
+
For `admin/users#edit` action, since `prefix_options` option is set, `edit` will be mapped to `form`, and `form` will be added to the prefixes as well.
|
78
85
|
Therefore, the lookup folder order of `admin/users#edit` becomes:
|
79
86
|
|
87
|
+
- app/views/admin/users/edit
|
80
88
|
- app/views/admin/users/form
|
81
89
|
- app/views/admin/users
|
90
|
+
- app/views/secure/edit
|
82
91
|
- app/views/secure/form
|
83
92
|
- app/views/secure
|
93
|
+
- app/views/admin/application/edit
|
84
94
|
- app/views/admin/application/form
|
85
95
|
- app/views/admin/application
|
96
|
+
- app/views/secure/edit
|
86
97
|
- app/views/secure/form
|
87
98
|
- app/views/secure
|
99
|
+
- app/views/application/edit
|
88
100
|
- app/views/application/form
|
89
101
|
- app/views/application
|
90
102
|
|
103
|
+
## Advanced Usage
|
104
|
+
|
105
|
+
It is possible to override the `_prefixes` method to make more changes to the prefixes before suffixing them with the action name:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
class ApplicationController < ActionController::Base
|
109
|
+
include Wallaby::View
|
110
|
+
|
111
|
+
def _prefixes
|
112
|
+
super do |prefixes|
|
113
|
+
prefixes << 'last_resort'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
```
|
118
|
+
|
119
|
+
Then the lookup folder order of e.g. `application#edit` becomes:
|
120
|
+
|
121
|
+
- app/views/application/edit
|
122
|
+
- app/views/application
|
123
|
+
- app/views/last_resort/edit
|
124
|
+
- app/views/last_resort
|
125
|
+
|
91
126
|
## Documentation
|
92
127
|
|
93
128
|
- [API Reference](https://www.rubydoc.info/gems/wallaby-view)
|
@@ -7,17 +7,22 @@ module Wallaby
|
|
7
7
|
module ActionViewable
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
|
11
|
-
# @!attribute prefix_options
|
12
|
-
# It stores the options for {#_prefixes}. It can inherit options from superclass.
|
13
|
-
# @return [Hash] prefix options
|
14
|
-
end
|
15
|
-
|
16
|
-
class_methods do
|
10
|
+
module ClassMethods # :nodoc:
|
11
|
+
# @!attribute [w] prefix_options
|
17
12
|
attr_writer :prefix_options
|
18
13
|
|
14
|
+
# @!attribute [r] prefix_options
|
15
|
+
# It stores the options for {#_prefixes #_prefixes}. It can inherit options from superclass.
|
16
|
+
# @return [Hash] prefix options
|
19
17
|
def prefix_options
|
20
|
-
@prefix_options ||= superclass.try(:prefix_options)
|
18
|
+
@prefix_options ||= superclass.try(:prefix_options).try(:dup) || {}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add prefix options
|
22
|
+
# @param new_options [Hash]
|
23
|
+
# @return [Hash] merged prefix options
|
24
|
+
def merge_prefix_options(new_options)
|
25
|
+
prefix_options.merge!(new_options)
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
@@ -33,7 +38,7 @@ module Wallaby
|
|
33
38
|
# Override
|
34
39
|
# {https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L97 lookup_context}
|
35
40
|
# to provide caching for template/partial lookup.
|
36
|
-
# @return {
|
41
|
+
# @return {CustomLookupContext}
|
37
42
|
|
38
43
|
# (see #lookup_context)
|
39
44
|
def override_lookup_context
|
@@ -43,12 +48,12 @@ module Wallaby
|
|
43
48
|
|
44
49
|
# @!method _prefixes(prefixes: nil, controller_path: nil, action_name: nil, themes: nil, options: nil, &block)
|
45
50
|
# Override {https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L90 _prefixes}
|
46
|
-
# to allow other (e.g. {
|
47
|
-
# {
|
51
|
+
# to allow other (e.g. {CustomPrefixes#action_name},
|
52
|
+
# {CustomPrefixes#themes}) to be added to the prefixes list.
|
48
53
|
# @param prefixes [Array<String>] the base prefixes
|
49
54
|
# @param action_name [String] the action name to add to the prefixes list
|
50
55
|
# @param themes [String] the theme name to add to the prefixes list
|
51
|
-
# @param options [Hash] the options
|
56
|
+
# @param options [Hash] the options that {CustomPrefixes} accepts
|
52
57
|
# @return [Array<String>]
|
53
58
|
|
54
59
|
# (see #_prefixes)
|
@@ -63,7 +68,7 @@ module Wallaby
|
|
63
68
|
prefixes: prefixes || original_prefixes,
|
64
69
|
action_name: action_name || params[:action],
|
65
70
|
themes: themes || self.class.themes,
|
66
|
-
options:
|
71
|
+
options: self.class.prefix_options.merge(options || {}), &block
|
67
72
|
)
|
68
73
|
end
|
69
74
|
end
|
@@ -4,11 +4,11 @@ module Wallaby
|
|
4
4
|
module View
|
5
5
|
# Custom lookup context to cache lookup results.
|
6
6
|
class CustomLookupContext < ::ActionView::LookupContext
|
7
|
-
# Convert an ActionView::LookupContext instance into {
|
7
|
+
# Convert an ActionView::LookupContext instance into {CustomLookupContext}
|
8
8
|
# @param lookup_context [ActionView::LookupContext]
|
9
9
|
# @param details [Hash]
|
10
10
|
# @param prefixes [Array<String>]
|
11
|
-
# @return [
|
11
|
+
# @return [CustomLookupContext]
|
12
12
|
def self.convert(lookup_context, details: nil, prefixes: nil)
|
13
13
|
return lookup_context if lookup_context.is_a? self
|
14
14
|
|
@@ -7,17 +7,20 @@ module Wallaby
|
|
7
7
|
# @!attribute [r] prefixes
|
8
8
|
# Base prefixes to extend
|
9
9
|
# @return [Array<String>]
|
10
|
-
# @see
|
10
|
+
# @see ActionViewable#_prefixes
|
11
11
|
attr_reader :prefixes
|
12
|
+
|
12
13
|
# @!attribute [r] action_name
|
13
14
|
# Action name to be added
|
14
15
|
# @return [String]
|
15
16
|
attr_reader :action_name
|
17
|
+
|
16
18
|
# @!attribute [r] themes
|
17
19
|
# Themes to be inserted
|
18
20
|
# @return [Array<Hash>]
|
19
|
-
# @see
|
21
|
+
# @see Themeable#.themes
|
20
22
|
attr_reader :themes
|
23
|
+
|
21
24
|
# @!attribute [r] options
|
22
25
|
# Options for extending the given prefixes
|
23
26
|
# @return [Hash]
|
@@ -28,6 +31,7 @@ module Wallaby
|
|
28
31
|
# Wallaby::View::CustomPrefixes.execute(
|
29
32
|
# prefixes: ['users', 'application'], action_name: 'index'
|
30
33
|
# )
|
34
|
+
#
|
31
35
|
# # => [
|
32
36
|
# # 'users/index',
|
33
37
|
# # 'users',
|
@@ -39,6 +43,7 @@ module Wallaby
|
|
39
43
|
# prefixes: ['users', 'application'], action_name: 'index',
|
40
44
|
# themes: [{ theme_name: 'secure', theme_path: 'users' }]
|
41
45
|
# )
|
46
|
+
#
|
42
47
|
# # => [
|
43
48
|
# # 'users/index',
|
44
49
|
# # 'users',
|
@@ -50,8 +55,9 @@ module Wallaby
|
|
50
55
|
# @example To extend given prefixes with mapped action:
|
51
56
|
# Wallaby::View::CustomPrefixes.execute(
|
52
57
|
# prefixes: ['users', 'application'], action_name: 'edit',
|
53
|
-
# options: {
|
58
|
+
# options: { 'edit' => 'form' }
|
54
59
|
# )
|
60
|
+
#
|
55
61
|
# # => [
|
56
62
|
# # 'users/form',
|
57
63
|
# # 'users',
|
@@ -88,35 +94,37 @@ module Wallaby
|
|
88
94
|
# @return [Array<String>]
|
89
95
|
def execute(&block)
|
90
96
|
new_prefixes(&block).each_with_object([]) do |prefix, array|
|
91
|
-
# Extend the prefix with
|
92
|
-
array << "#{prefix}/#{
|
97
|
+
# Extend the prefix with actions
|
98
|
+
actions.each { |action| array << "#{prefix}/#{action}" }
|
99
|
+
array << prefix
|
93
100
|
end
|
94
101
|
end
|
95
102
|
|
96
|
-
|
103
|
+
protected
|
97
104
|
|
105
|
+
# @yield [array] To allow the array to be further modified
|
106
|
+
# @yieldparam [Array<String>] array
|
98
107
|
# @return [Array<String>]
|
99
108
|
def new_prefixes
|
100
109
|
prefixes.dup.try do |array|
|
101
110
|
insert_themes_into array
|
102
111
|
|
103
112
|
# Be able to change the array in overriding methods
|
104
|
-
# in {
|
113
|
+
# in {ActionViewable#override_prefixes}
|
105
114
|
new_array = yield array if block_given?
|
106
115
|
|
107
|
-
# If the above block doesn't return
|
108
|
-
# it's assumed that `array` is changed
|
116
|
+
# If the above block doesn't return a new array, it returns the old `array`.
|
109
117
|
new_array.is_a?(Array) ? new_array : array
|
110
118
|
end
|
111
119
|
end
|
112
120
|
|
113
|
-
# Action
|
114
|
-
|
115
|
-
|
116
|
-
@suffix ||= mapped_action_name || action_name
|
121
|
+
# @return [Array<String>] Action names
|
122
|
+
def actions
|
123
|
+
@actions ||= [action_name, *mapped_action_name].compact
|
117
124
|
end
|
118
125
|
|
119
|
-
# Insert theme
|
126
|
+
# Insert theme names into the prefixes
|
127
|
+
# @param [Array<String>] array
|
120
128
|
def insert_themes_into(array)
|
121
129
|
themes.each do |theme|
|
122
130
|
index = array.index theme[:theme_path]
|
@@ -125,9 +133,9 @@ module Wallaby
|
|
125
133
|
end
|
126
134
|
|
127
135
|
# Map the {#action_name} using `options[:mapping_actions]`
|
128
|
-
# @return [String
|
136
|
+
# @return [Array<String>] mapped action name
|
129
137
|
def mapped_action_name
|
130
|
-
options[:mapping_actions].try(:[], action_name)
|
138
|
+
Array((options[:mapping_actions] || options).try(:[], action_name))
|
131
139
|
end
|
132
140
|
end
|
133
141
|
end
|
@@ -6,8 +6,7 @@ module Wallaby
|
|
6
6
|
module Themeable
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
-
|
10
|
-
# @!attribute theme_name
|
9
|
+
module ClassMethods # :nodoc:
|
11
10
|
# The theme name is used to specify the layout and prefixes
|
12
11
|
# so that a set of theme implementation for the frontend (html/css/javascript)
|
13
12
|
# can be applied
|
@@ -27,6 +26,7 @@ module Wallaby
|
|
27
26
|
#
|
28
27
|
# def index
|
29
28
|
# _prefixes
|
29
|
+
#
|
30
30
|
# # =>
|
31
31
|
# # [
|
32
32
|
# # 'admin/application/index',
|
@@ -37,8 +37,22 @@ module Wallaby
|
|
37
37
|
# # 'application'
|
38
38
|
# # ]
|
39
39
|
# end
|
40
|
-
#
|
40
|
+
# end
|
41
|
+
# @param theme_name [String]
|
42
|
+
# @param options [Hash] same options as Rails'
|
43
|
+
# {https://api.rubyonrails.org/classes/ActionView/Layouts/ClassMethods.html#method-i-layout
|
44
|
+
# layout} method
|
45
|
+
def theme_name=(theme_name, **options, &block)
|
46
|
+
layout theme_name, options, &block
|
47
|
+
@theme_path = theme_name && controller_path || nil
|
48
|
+
@theme_name = theme_name || nil
|
49
|
+
end
|
50
|
+
|
51
|
+
# @!attribute [r] theme_name
|
41
52
|
# @return [String, nil] theme name
|
53
|
+
def theme_name
|
54
|
+
defined?(@theme_name) && @theme_name || superclass.try(:theme_name)
|
55
|
+
end
|
42
56
|
|
43
57
|
# @!attribute [r] theme
|
44
58
|
# @example Once theme is set, the metadata will be set as well:
|
@@ -46,6 +60,7 @@ module Wallaby
|
|
46
60
|
# self.theme_name = 'secure'
|
47
61
|
#
|
48
62
|
# self.theme
|
63
|
+
#
|
49
64
|
# # =>
|
50
65
|
# # {
|
51
66
|
# # theme_name: 'secure',
|
@@ -53,25 +68,6 @@ module Wallaby
|
|
53
68
|
# # }
|
54
69
|
# end
|
55
70
|
# @return [Hash] theme metadata
|
56
|
-
|
57
|
-
# @!attribute [r] themes
|
58
|
-
# @return [Array<Hash>] a list of {.theme} metadata
|
59
|
-
end
|
60
|
-
|
61
|
-
class_methods do
|
62
|
-
# (see .theme_name)
|
63
|
-
def theme_name=(theme_name, **options, &block)
|
64
|
-
layout theme_name, options, &block
|
65
|
-
@theme_path = theme_name && controller_path || nil
|
66
|
-
@theme_name = theme_name || nil
|
67
|
-
end
|
68
|
-
|
69
|
-
# (see .theme_name)
|
70
|
-
def theme_name
|
71
|
-
defined?(@theme_name) && @theme_name || superclass.try(:theme_name)
|
72
|
-
end
|
73
|
-
|
74
|
-
# (see .theme)
|
75
71
|
def theme
|
76
72
|
defined?(@theme_name) && @theme_name && {
|
77
73
|
theme_name: @theme_name,
|
@@ -79,7 +75,8 @@ module Wallaby
|
|
79
75
|
} || superclass.try(:theme)
|
80
76
|
end
|
81
77
|
|
82
|
-
#
|
78
|
+
# @!attribute [r] themes
|
79
|
+
# @return [Array<Hash>] a list of {#theme} metadata
|
83
80
|
def themes
|
84
81
|
list = superclass.try(:themes) || []
|
85
82
|
list.prepend theme if defined?(@theme_name) && @theme_name
|
data/lib/wallaby/view/version.rb
CHANGED
data/lib/wallaby/view.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'request_store'
|
4
|
-
require 'action_view/partial_renderer'
|
5
|
-
|
6
3
|
require 'wallaby/view/version'
|
7
4
|
require 'wallaby/view/action_viewable'
|
8
5
|
require 'wallaby/view/themeable'
|
@@ -11,35 +8,18 @@ require 'wallaby/view/custom_prefixes'
|
|
11
8
|
|
12
9
|
module Wallaby # :nodoc:
|
13
10
|
# To extend Rails prefixes and improve lookup performance.
|
11
|
+
#
|
12
|
+
# For example, include {Wallaby::View} module in the controller:
|
13
|
+
#
|
14
|
+
# ```
|
15
|
+
# # app/controllers/application_controller
|
16
|
+
# class ApplicationController < ActionController::Base
|
17
|
+
# include Wallaby::View
|
18
|
+
# end
|
19
|
+
# ```
|
14
20
|
module View
|
15
21
|
extend ActiveSupport::Concern
|
16
22
|
|
17
|
-
# This is the method executed when this module is included by other modules.
|
18
|
-
#
|
19
|
-
# Basically, it renames the methods so that it is possible
|
20
|
-
# to access the original methods after overriding them:
|
21
|
-
#
|
22
|
-
# 1. Rename the following original methods:
|
23
|
-
#
|
24
|
-
# - rename {https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L97
|
25
|
-
# lookup_context} to {Wallaby::View::ActionViewable#original_lookup_context original_lookup_context}
|
26
|
-
# - rename {https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L90 _prefixes}
|
27
|
-
# to {Wallaby::View::ActionViewable#original_prefixes original_prefixes}
|
28
|
-
#
|
29
|
-
# 2. Override the original methods:
|
30
|
-
#
|
31
|
-
# - rename {Wallaby::View::ActionViewable#override_lookup_context override_lookup_context}
|
32
|
-
# to {Wallaby::View::ActionViewable#lookup_context lookup_context}
|
33
|
-
# - rename {Wallaby::View::ActionViewable#override_prefixes override_prefixes}
|
34
|
-
# to {Wallaby::View::ActionViewable#\_prefixes \_prefixes}
|
35
|
-
# @param mod [Module]
|
36
|
-
def self.included(mod)
|
37
|
-
mod.send :alias_method, :original_lookup_context, :lookup_context
|
38
|
-
mod.send :alias_method, :original_prefixes, :_prefixes
|
39
|
-
mod.send :alias_method, :lookup_context, :override_lookup_context
|
40
|
-
mod.send :alias_method, :_prefixes, :override_prefixes
|
41
|
-
end
|
42
|
-
|
43
23
|
COMMA = ',' # :nodoc:
|
44
24
|
EMPTY_STRING = '' # :nodoc:
|
45
25
|
DOT_RB = '.rb' # :nodoc:
|
@@ -49,5 +29,14 @@ module Wallaby # :nodoc:
|
|
49
29
|
|
50
30
|
include ActionViewable
|
51
31
|
include Themeable
|
32
|
+
|
33
|
+
included do
|
34
|
+
# NOTE: Basically, it renames the methods so that it is possible
|
35
|
+
# to access the original methods after overriding them:
|
36
|
+
alias_method :original_lookup_context, :lookup_context
|
37
|
+
alias_method :original_prefixes, :_prefixes
|
38
|
+
alias_method :lookup_context, :override_lookup_context
|
39
|
+
alias_method :_prefixes, :override_prefixes
|
40
|
+
end
|
52
41
|
end
|
53
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wallaby-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tian Chen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -25,13 +25,13 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: github-markup
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -39,7 +39,35 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: redcarpet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - ">="
|
@@ -66,6 +94,20 @@ dependencies:
|
|
66
94
|
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description: Wallaby View to extend Rails layout/template/partial inheritance chain.
|
70
112
|
email:
|
71
113
|
- me@tian.im
|
@@ -75,7 +117,6 @@ extra_rdoc_files: []
|
|
75
117
|
files:
|
76
118
|
- LICENSE
|
77
119
|
- README.md
|
78
|
-
- lib/action_view/partial_renderer.rb
|
79
120
|
- lib/wallaby/view.rb
|
80
121
|
- lib/wallaby/view/action_viewable.rb
|
81
122
|
- lib/wallaby/view/custom_lookup_context.rb
|
@@ -86,10 +127,11 @@ homepage: https://github.com/wallaby-rails/wallaby-view
|
|
86
127
|
licenses:
|
87
128
|
- MIT
|
88
129
|
metadata:
|
130
|
+
rubygems_mfa_required: 'true'
|
89
131
|
homepage_uri: https://github.com/wallaby-rails/wallaby-view
|
90
132
|
source_code_uri: https://github.com/wallaby-rails/wallaby-view
|
91
133
|
changelog_uri: https://github.com/wallaby-rails/wallaby-view/blob/master/CHANGELOG.md
|
92
|
-
post_install_message:
|
134
|
+
post_install_message:
|
93
135
|
rdoc_options: []
|
94
136
|
require_paths:
|
95
137
|
- lib
|
@@ -104,8 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
146
|
- !ruby/object:Gem::Version
|
105
147
|
version: '0'
|
106
148
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
108
|
-
signing_key:
|
149
|
+
rubygems_version: 3.1.2
|
150
|
+
signing_key:
|
109
151
|
specification_version: 4
|
110
152
|
summary: Wallaby View to extend Rails layout/template/partial inheritance chain.
|
111
153
|
test_files: []
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActionView # :nodoc:
|
4
|
-
# Re-open ActionView::PartialRenderer to disable logging for partials
|
5
|
-
# that have been rendered for more than once.
|
6
|
-
#
|
7
|
-
# Every log requires the IO. Reducing the logs will dramatically improve the performance.
|
8
|
-
# @see #instrument
|
9
|
-
class PartialRenderer
|
10
|
-
protected
|
11
|
-
|
12
|
-
# @!method original_instrument(name, **options, &block)
|
13
|
-
# Original method of {#instrument}
|
14
|
-
# @param name [String]
|
15
|
-
# @param options [Hash]
|
16
|
-
# @yield [payload]
|
17
|
-
# @yieldparam payload [Hash] payload object for instrument
|
18
|
-
# @return [ActionView::OutputBuffer]
|
19
|
-
alias original_instrument instrument
|
20
|
-
|
21
|
-
# Logs for partial rendering. Only one log will be printed
|
22
|
-
# even if a partial has been rendered for more than once.
|
23
|
-
#
|
24
|
-
# To disable this feature and see all logs,
|
25
|
-
# set `ENV['ALL_PARTIAL_LOGS']` to `true`
|
26
|
-
# @param name [String]
|
27
|
-
# @param options [Hash]
|
28
|
-
# @yield [payload]
|
29
|
-
# @yieldparam payload [Hash] payload object for instrument
|
30
|
-
# @return [ActionView::OutputBuffer]
|
31
|
-
def instrument(name, **options, &block)
|
32
|
-
identifier = options[:identifier] || @template.try(:identifier) || @path
|
33
|
-
instrumented = RequestStore.store[:instrumented] ||= {}
|
34
|
-
|
35
|
-
return yield({}) if !ENV['ALL_PARTIAL_LOGS'] && instrumented[identifier]
|
36
|
-
|
37
|
-
original_instrument(name, **options, &block).tap do
|
38
|
-
instrumented[identifier] ||= true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|