render_parent 0.0.8 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 257da0e40c94fd1a57fa8bdbf668b0ec3efdb4b8
4
- data.tar.gz: 871e1ca0f4439916b0510eb0d85f5e0141cedf16
2
+ SHA256:
3
+ metadata.gz: 146b2ecebd56388e965f6eac412b7f47a019e1561c02b8dd75038e2814e9fe10
4
+ data.tar.gz: 7b31323be1a7a6807fcac4118e370d17d8f4b6c3892373251927364fa5a14032
5
5
  SHA512:
6
- metadata.gz: db77041d9a60e6a1772fc9c23b27851f3b2c4930976e7444c981bdd07ae3762b9c7b59abcfe4f0aa2cf2b660ba63884c1bc70392351560ee489278694fdda4a5
7
- data.tar.gz: 6567b5847308069b56be8ef4528d56e3db2eece50907a69a2a3c7d5c45c2094d7fab00a6e338ec2199def20b3e942bd4c0ef470f3dd5774f45c5d65cd0cf995e
6
+ metadata.gz: 880a5b2c0c492dbc64dfc9372b760b80e96a00058358b0d454c6fbccbb901d67ec136146699699dc1ce60911431ec9b1c79a7d9e18c80981916be71caec5e7eb
7
+ data.tar.gz: 6e1857189a4164cc355b25adcd28a1ec169db5194589bf374975a890359379c1b4c597367b61ed5e4a01cbe1ceb90b0b023bfa66e22ba08173121f866f84702d
@@ -3,7 +3,7 @@
3
3
  Adds Rails "render :parent" helper, which renders template with the same name as current but higher on the view path
4
4
 
5
5
  == Contributing to render_parent
6
-
6
+
7
7
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
8
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
9
  * Fork the project.
@@ -14,6 +14,6 @@ Adds Rails "render :parent" helper, which renders template with the same name as
14
14
 
15
15
  == Copyright
16
16
 
17
- Copyright (c) 2012 Anton Argirov. See LICENSE.txt for
17
+ Copyright (c) 2019 Anton Argirov. See LICENSE.txt for
18
18
  further details.
19
19
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.summary = %Q{Adds Rails "render :parent" helper, which renders template with the same name as current but higher on the view path}
21
21
  gem.description = %Q{This version fixes render_collection}
22
22
  gem.email = "anton.argirov@gmail.com"
23
- gem.authors = ["Anton Argirov"]
23
+ gem.authors = ["Anton Argirov", "MayamaTakeshi"]
24
24
  gem.files = Dir.glob('lib/**/*.rb') + %w(.document Gemfile LICENSE.txt README.rdoc Rakefile VERSION)
25
25
  # dependencies defined in Gemfile
26
26
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -1,5 +1,7 @@
1
- if Rails::VERSION::MAJOR >= 3
1
+ if Rails::VERSION::MAJOR >= 5
2
+ require 'render_parent/rails5'
3
+ elsif Rails::VERSION::MAJOR >= 3
2
4
  require 'render_parent/rails3'
3
5
  elsif Rails::VERSION::MAJOR == 2
4
6
  require 'render_parent/rails2'
5
- end
7
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails'
2
+
3
+ module RenderParent
4
+ class Railtie < Rails::Railtie
5
+ initializer "render_parent.initialize" do
6
+ ActiveSupport.on_load(:action_controller) do
7
+ require 'render_parent/rails3/on_load_action_controller'
8
+ end
9
+ ActiveSupport.on_load(:action_mailer) do
10
+ require 'render_parent/rails3/on_load_action_mailer'
11
+ end
12
+ ActiveSupport.on_load(:action_view) do
13
+ require 'render_parent/rails5/on_load_action_view'
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ ActionView::Base.class_eval do
2
+ def render_parent_template(locals = {}, &block)
3
+ template = controller.active_template
4
+ view_paths.exclusions << template
5
+ locals["__rendered_depth_#{view_paths.exclusions.count}"] = true
6
+ handlers = ActionView::Template::Handlers.extensions.select do |ext|
7
+ ActionView::Template.handler_for_extension(ext) == template.handler
8
+ end
9
+ result = render(:template => template.virtual_path,
10
+ :formats => template.formats,
11
+ :handlers => handlers,
12
+ :locals => locals, &block)
13
+ view_paths.exclusions.delete template
14
+ result
15
+ end
16
+
17
+ def render_with_parent(options = {}, locals = {}, &block)
18
+ if options == :parent
19
+ render_parent_template(locals, &block)
20
+ else
21
+ render_without_parent(options, locals, &block)
22
+ end
23
+ end
24
+
25
+ alias_method :render_without_parent, :render
26
+ alias_method :render, :render_with_parent
27
+ end
28
+
29
+ ActionView::PathSet.class_eval do
30
+ attr_writer :exclusions
31
+
32
+ def exclusions
33
+ @exclusions ||= []
34
+ end
35
+
36
+ def find_all_with_exclusions(path, prefixes = [], *args)
37
+ excluded = exclusions.map(&:identifier)
38
+ prefixes = [prefixes] if String === prefixes
39
+ prefixes.each do |prefix|
40
+ paths.each do |resolver|
41
+ templates = resolver.find_all(path, prefix, *args)
42
+ templates.delete_if {|t| excluded.include? t.identifier} unless templates.empty?
43
+ return templates unless templates.empty?
44
+ end
45
+ end
46
+ []
47
+ end
48
+
49
+ alias_method :find_all_without_exclusions, :find_all
50
+ alias_method :find_all, :find_all_with_exclusions
51
+ end
52
+
53
+ ActionView::Template.class_eval do
54
+ def render_with_active_template(view, locals, buffer=nil, &block)
55
+ template_stack = view.controller.respond_to?(:active_template_stack) && view.controller.active_template_stack
56
+ template_stack.push(self) if template_stack
57
+ result = render_without_active_template(view, locals, buffer, &block)
58
+ template_stack.pop if template_stack
59
+ result
60
+ end
61
+
62
+ alias_method :render_without_active_template, :render
63
+ alias_method :render, :render_with_active_template
64
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_parent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Argirov
8
+ - MayamaTakeshi
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-09-30 00:00:00.000000000 Z
12
+ date: 2019-11-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
@@ -73,6 +74,8 @@ files:
73
74
  - lib/render_parent/rails3/on_load_action_controller.rb
74
75
  - lib/render_parent/rails3/on_load_action_mailer.rb
75
76
  - lib/render_parent/rails3/on_load_action_view.rb
77
+ - lib/render_parent/rails5.rb
78
+ - lib/render_parent/rails5/on_load_action_view.rb
76
79
  homepage: http://github.com/anteo/render-parent
77
80
  licenses:
78
81
  - MIT
@@ -93,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
96
  version: '0'
94
97
  requirements: []
95
98
  rubyforge_project:
96
- rubygems_version: 2.5.1
99
+ rubygems_version: 2.7.7
97
100
  signing_key:
98
101
  specification_version: 4
99
102
  summary: Adds Rails "render :parent" helper, which renders template with the same