render_parent 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -5
- data/Gemfile +10 -10
- data/LICENSE.txt +20 -20
- data/README.rdoc +19 -19
- data/Rakefile +46 -44
- data/VERSION +1 -1
- data/lib/rails/init.rb +1 -1
- data/lib/render_parent.rb +4 -4
- data/lib/render_parent/rails2.rb +61 -61
- data/lib/render_parent/rails3.rb +16 -16
- data/lib/render_parent/rails3/on_load_action_controller.rb +10 -10
- data/lib/render_parent/rails3/on_load_action_mailer.rb +10 -10
- data/lib/render_parent/rails3/on_load_action_view.rb +75 -75
- metadata +20 -33
- data/test/helper.rb +0 -18
- data/test/test_render_parent.rb +0 -7
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 05f854b5c56d02e9463b1960fbb42d371daa260c
|
4
|
+
data.tar.gz: 474071be6019acd892b1e4de2ddad62aefa2fcf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f81d87a55e53e30088f94c8492068d5c4d0cbb18ca4042f6209fb53de50096b016f4e53da77988ee6633c3d0f84f12587ed21037e4d7d8608954c5ddedd5ba57
|
7
|
+
data.tar.gz: 8f5443fe9f5243130204fa65e17c8a6a9299bd9937e69fbcca1ecb2f71b0decd226a504282027086a4eeabff813bc282870b3ef51d961d8dd307ecf01c4b2b0a
|
data/.document
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
lib/**/*.rb
|
2
|
-
bin/*
|
3
|
-
-
|
4
|
-
features/**/*.feature
|
5
|
-
LICENSE.txt
|
1
|
+
lib/**/*.rb
|
2
|
+
bin/*
|
3
|
+
-
|
4
|
+
features/**/*.feature
|
5
|
+
LICENSE.txt
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
source
|
2
|
-
|
3
|
-
gem
|
4
|
-
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
|
-
group :development do
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
end
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '>= 2.3.0'
|
4
|
+
|
5
|
+
# Add dependencies to develop your gem here.
|
6
|
+
# Include everything needed to run rake, tests, features, etc.
|
7
|
+
group :development do
|
8
|
+
gem 'bundler'
|
9
|
+
gem 'jeweler'
|
10
|
+
end
|
data/LICENSE.txt
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2012 Anton Argirov
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2012 Anton Argirov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
= render_parent
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
== Contributing to render_parent
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2012 Anton Argirov. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|
1
|
+
= render_parent
|
2
|
+
|
3
|
+
Adds Rails "render :parent" helper, which renders template with the same name as current but higher on the view path
|
4
|
+
|
5
|
+
== Contributing to render_parent
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Anton Argirov. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
CHANGED
@@ -1,44 +1,46 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "render_parent"
|
18
|
-
gem.homepage = "http://
|
19
|
-
gem.license = "MIT"
|
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
|
-
gem.
|
22
|
-
gem.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
test.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
rdoc.
|
43
|
-
rdoc.
|
44
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "render_parent"
|
18
|
+
gem.homepage = "http://github.com/anteo/render-parent"
|
19
|
+
gem.license = "MIT"
|
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
|
+
gem.description = %Q{This version adds Rails 4 compatibility}
|
22
|
+
gem.email = "anton.argirov@gmail.com"
|
23
|
+
gem.authors = ["Anton Argirov"]
|
24
|
+
gem.files = Dir.glob('lib/**/*.rb') + %w(.document Gemfile LICENSE.txt README.rdoc Rakefile VERSION)
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
require 'rdoc/task'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "render_parent #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/rails/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'render_parent/rails2'
|
1
|
+
require 'render_parent/rails2'
|
data/lib/render_parent.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
if Rails::VERSION::MAJOR
|
2
|
-
require 'render_parent/rails3'
|
3
|
-
elsif Rails::VERSION::MAJOR == 2
|
4
|
-
require 'render_parent/rails2'
|
1
|
+
if Rails::VERSION::MAJOR >= 3
|
2
|
+
require 'render_parent/rails3'
|
3
|
+
elsif Rails::VERSION::MAJOR == 2
|
4
|
+
require 'render_parent/rails2'
|
5
5
|
end
|
data/lib/render_parent/rails2.rb
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
require 'action_view/base'
|
2
|
-
|
3
|
-
ActionView::Base.class_eval do
|
4
|
-
def render_parent_template(local_assigns = {}, &block)
|
5
|
-
view_paths.exclusions << template
|
6
|
-
result = render(:file => template.to_s, :locals => local_assigns, &block)
|
7
|
-
view_paths.exclusions.delete template
|
8
|
-
result
|
9
|
-
end
|
10
|
-
|
11
|
-
def render_with_parent(options = {}, local_assigns = {}, &block)
|
12
|
-
if options == :parent
|
13
|
-
render_parent_template(local_assigns, &block)
|
14
|
-
else
|
15
|
-
render_without_parent(options, local_assigns, &block)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
alias_method_chain :render, :parent
|
20
|
-
end
|
21
|
-
|
22
|
-
ActionView::PathSet.class_eval do
|
23
|
-
attr_writer :exclusions
|
24
|
-
|
25
|
-
def exclusions
|
26
|
-
@exclusions ||= []
|
27
|
-
end
|
28
|
-
|
29
|
-
def find_template(original_template_path, format = nil, html_fallback = true)
|
30
|
-
return original_template_path if original_template_path.respond_to?(:render)
|
31
|
-
template_path = original_template_path.sub(/^\//, '')
|
32
|
-
|
33
|
-
each do |load_path|
|
34
|
-
if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"]) && !exclusions.include?(template)
|
35
|
-
return template
|
36
|
-
# Try the default locale version if the current locale doesn't have one
|
37
|
-
# (i.e. you haven't translated this view to German yet, but you have the English version on hand)
|
38
|
-
elsif format && (template = load_path["#{template_path}.#{I18n.default_locale}.#{format}"]) && !exclusions.include?(template)
|
39
|
-
return template
|
40
|
-
elsif format && (template = load_path["#{template_path}.#{format}"]) && !exclusions.include?(template)
|
41
|
-
return template
|
42
|
-
elsif (template = load_path["#{template_path}.#{I18n.locale}"]) && !exclusions.include?(template)
|
43
|
-
return template
|
44
|
-
elsif (template = load_path["#{template_path}.#{I18n.default_locale}"]) && !exclusions.include?(template)
|
45
|
-
return template
|
46
|
-
elsif (template = load_path[template_path]) && !exclusions.include?(template)
|
47
|
-
return template
|
48
|
-
# Try to find html version if the format is javascript
|
49
|
-
elsif format == :js && html_fallback && (template = load_path["#{template_path}.#{I18n.locale}.html"]) && !exclusions.include?(template)
|
50
|
-
return template
|
51
|
-
elsif format == :js && html_fallback && (template = load_path["#{template_path}.#{I18n.default_locale}.html"]) && !exclusions.include?(template)
|
52
|
-
return template
|
53
|
-
elsif format == :js && html_fallback && (template = load_path["#{template_path}.html"]) && !exclusions.include?(template)
|
54
|
-
return template
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
return ActionView::Template.new(original_template_path) if File.file?(original_template_path)
|
59
|
-
|
60
|
-
raise ActionView::MissingTemplate.new(self, original_template_path, format)
|
61
|
-
end
|
1
|
+
require 'action_view/base'
|
2
|
+
|
3
|
+
ActionView::Base.class_eval do
|
4
|
+
def render_parent_template(local_assigns = {}, &block)
|
5
|
+
view_paths.exclusions << template
|
6
|
+
result = render(:file => template.to_s, :locals => local_assigns, &block)
|
7
|
+
view_paths.exclusions.delete template
|
8
|
+
result
|
9
|
+
end
|
10
|
+
|
11
|
+
def render_with_parent(options = {}, local_assigns = {}, &block)
|
12
|
+
if options == :parent
|
13
|
+
render_parent_template(local_assigns, &block)
|
14
|
+
else
|
15
|
+
render_without_parent(options, local_assigns, &block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias_method_chain :render, :parent
|
20
|
+
end
|
21
|
+
|
22
|
+
ActionView::PathSet.class_eval do
|
23
|
+
attr_writer :exclusions
|
24
|
+
|
25
|
+
def exclusions
|
26
|
+
@exclusions ||= []
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_template(original_template_path, format = nil, html_fallback = true)
|
30
|
+
return original_template_path if original_template_path.respond_to?(:render)
|
31
|
+
template_path = original_template_path.sub(/^\//, '')
|
32
|
+
|
33
|
+
each do |load_path|
|
34
|
+
if format && (template = load_path["#{template_path}.#{I18n.locale}.#{format}"]) && !exclusions.include?(template)
|
35
|
+
return template
|
36
|
+
# Try the default locale version if the current locale doesn't have one
|
37
|
+
# (i.e. you haven't translated this view to German yet, but you have the English version on hand)
|
38
|
+
elsif format && (template = load_path["#{template_path}.#{I18n.default_locale}.#{format}"]) && !exclusions.include?(template)
|
39
|
+
return template
|
40
|
+
elsif format && (template = load_path["#{template_path}.#{format}"]) && !exclusions.include?(template)
|
41
|
+
return template
|
42
|
+
elsif (template = load_path["#{template_path}.#{I18n.locale}"]) && !exclusions.include?(template)
|
43
|
+
return template
|
44
|
+
elsif (template = load_path["#{template_path}.#{I18n.default_locale}"]) && !exclusions.include?(template)
|
45
|
+
return template
|
46
|
+
elsif (template = load_path[template_path]) && !exclusions.include?(template)
|
47
|
+
return template
|
48
|
+
# Try to find html version if the format is javascript
|
49
|
+
elsif format == :js && html_fallback && (template = load_path["#{template_path}.#{I18n.locale}.html"]) && !exclusions.include?(template)
|
50
|
+
return template
|
51
|
+
elsif format == :js && html_fallback && (template = load_path["#{template_path}.#{I18n.default_locale}.html"]) && !exclusions.include?(template)
|
52
|
+
return template
|
53
|
+
elsif format == :js && html_fallback && (template = load_path["#{template_path}.html"]) && !exclusions.include?(template)
|
54
|
+
return template
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
return ActionView::Template.new(original_template_path) if File.file?(original_template_path)
|
59
|
+
|
60
|
+
raise ActionView::MissingTemplate.new(self, original_template_path, format)
|
61
|
+
end
|
62
62
|
end
|
data/lib/render_parent/rails3.rb
CHANGED
@@ -1,17 +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/rails3/on_load_action_view'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
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/rails3/on_load_action_view'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'action_controller/base'
|
2
|
-
|
3
|
-
ActionController::Base.class_eval do
|
4
|
-
def active_template_stack
|
5
|
-
@active_template_stack ||= []
|
6
|
-
end
|
7
|
-
|
8
|
-
def active_template
|
9
|
-
@active_template_stack.last
|
10
|
-
end
|
1
|
+
require 'action_controller/base'
|
2
|
+
|
3
|
+
ActionController::Base.class_eval do
|
4
|
+
def active_template_stack
|
5
|
+
@active_template_stack ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def active_template
|
9
|
+
@active_template_stack.last
|
10
|
+
end
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'action_mailer/base'
|
2
|
-
|
3
|
-
ActionMailer::Base.class_eval do
|
4
|
-
def active_template_stack
|
5
|
-
@active_template_stack ||= []
|
6
|
-
end
|
7
|
-
|
8
|
-
def active_template
|
9
|
-
@active_template_stack.last
|
10
|
-
end
|
1
|
+
require 'action_mailer/base'
|
2
|
+
|
3
|
+
ActionMailer::Base.class_eval do
|
4
|
+
def active_template_stack
|
5
|
+
@active_template_stack ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def active_template
|
9
|
+
@active_template_stack.last
|
10
|
+
end
|
11
11
|
end
|
@@ -1,76 +1,76 @@
|
|
1
|
-
require 'action_view/helpers/rendering_helper'
|
2
|
-
require 'action_view/renderer/template_renderer'
|
3
|
-
|
4
|
-
ActionView::Helpers::RenderingHelper.module_eval do
|
5
|
-
def render_parent_template(locals = {}, &block)
|
6
|
-
template = controller.active_template
|
7
|
-
view_paths.exclusions << template
|
8
|
-
locals["__rendered_depth_#{view_paths.exclusions.count}"] = true
|
9
|
-
handlers = ActionView::Template::Handlers.extensions.select do |ext|
|
10
|
-
ActionView::Template.handler_for_extension(ext) == template.handler
|
11
|
-
end
|
12
|
-
result = render(:template => template.virtual_path,
|
13
|
-
:formats => template.formats,
|
14
|
-
:handlers => handlers,
|
15
|
-
:locals => locals, &block)
|
16
|
-
view_paths.exclusions.delete template
|
17
|
-
result
|
18
|
-
end
|
19
|
-
|
20
|
-
def render_with_parent(options = {}, locals = {}, &block)
|
21
|
-
if options == :parent
|
22
|
-
render_parent_template(locals, &block)
|
23
|
-
else
|
24
|
-
render_without_parent(options, locals, &block)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
alias_method_chain :render, :parent
|
29
|
-
end
|
30
|
-
|
31
|
-
ActionView::PathSet.class_eval do
|
32
|
-
attr_writer :exclusions
|
33
|
-
|
34
|
-
def exclusions
|
35
|
-
@exclusions ||= []
|
36
|
-
end
|
37
|
-
|
38
|
-
def find_all_with_exclusions(path, prefixes = [], *args)
|
39
|
-
excluded = exclusions.map(&:identifier)
|
40
|
-
prefixes = [prefixes] if String === prefixes
|
41
|
-
prefixes.each do |prefix|
|
42
|
-
paths.each do |resolver|
|
43
|
-
templates = resolver.find_all(path, prefix, *args)
|
44
|
-
templates.delete_if {|t| excluded.include? t.identifier}
|
45
|
-
return templates unless templates.empty?
|
46
|
-
end
|
47
|
-
end
|
48
|
-
[]
|
49
|
-
end
|
50
|
-
|
51
|
-
alias_method_chain :find_all, :exclusions
|
52
|
-
end
|
53
|
-
|
54
|
-
ActionView::TemplateRenderer.class_eval do
|
55
|
-
def render_template_with_active_template(template, layout_name = nil, locals = {})
|
56
|
-
template_stack = @view.controller.respond_to?(:active_template_stack) && @view.controller.active_template_stack
|
57
|
-
template_stack.push(template) if template_stack
|
58
|
-
result = render_template_without_active_template( template, layout_name, locals)
|
59
|
-
template_stack.pop if template_stack
|
60
|
-
result
|
61
|
-
end
|
62
|
-
|
63
|
-
alias_method_chain :render_template, :active_template
|
64
|
-
end
|
65
|
-
|
66
|
-
ActionView::PartialRenderer.class_eval do
|
67
|
-
def render_partial_with_active_template
|
68
|
-
template_stack = @view.controller.respond_to?(:active_template_stack) && @view.controller.active_template_stack
|
69
|
-
template_stack.push(@template) if template_stack
|
70
|
-
result = render_partial_without_active_template
|
71
|
-
template_stack.pop if template_stack
|
72
|
-
result
|
73
|
-
end
|
74
|
-
|
75
|
-
alias_method_chain :render_partial, :active_template
|
1
|
+
require 'action_view/helpers/rendering_helper'
|
2
|
+
require 'action_view/renderer/template_renderer'
|
3
|
+
|
4
|
+
ActionView::Helpers::RenderingHelper.module_eval do
|
5
|
+
def render_parent_template(locals = {}, &block)
|
6
|
+
template = controller.active_template
|
7
|
+
view_paths.exclusions << template
|
8
|
+
locals["__rendered_depth_#{view_paths.exclusions.count}"] = true
|
9
|
+
handlers = ActionView::Template::Handlers.extensions.select do |ext|
|
10
|
+
ActionView::Template.handler_for_extension(ext) == template.handler
|
11
|
+
end
|
12
|
+
result = render(:template => template.virtual_path,
|
13
|
+
:formats => template.formats,
|
14
|
+
:handlers => handlers,
|
15
|
+
:locals => locals, &block)
|
16
|
+
view_paths.exclusions.delete template
|
17
|
+
result
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_with_parent(options = {}, locals = {}, &block)
|
21
|
+
if options == :parent
|
22
|
+
render_parent_template(locals, &block)
|
23
|
+
else
|
24
|
+
render_without_parent(options, locals, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method_chain :render, :parent
|
29
|
+
end
|
30
|
+
|
31
|
+
ActionView::PathSet.class_eval do
|
32
|
+
attr_writer :exclusions
|
33
|
+
|
34
|
+
def exclusions
|
35
|
+
@exclusions ||= []
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_all_with_exclusions(path, prefixes = [], *args)
|
39
|
+
excluded = exclusions.map(&:identifier)
|
40
|
+
prefixes = [prefixes] if String === prefixes
|
41
|
+
prefixes.each do |prefix|
|
42
|
+
paths.each do |resolver|
|
43
|
+
templates = resolver.find_all(path, prefix, *args)
|
44
|
+
templates.delete_if {|t| excluded.include? t.identifier} unless templates.empty?
|
45
|
+
return templates unless templates.empty?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
[]
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_method_chain :find_all, :exclusions
|
52
|
+
end
|
53
|
+
|
54
|
+
ActionView::TemplateRenderer.class_eval do
|
55
|
+
def render_template_with_active_template(template, layout_name = nil, locals = {})
|
56
|
+
template_stack = @view.controller.respond_to?(:active_template_stack) && @view.controller.active_template_stack
|
57
|
+
template_stack.push(template) if template_stack
|
58
|
+
result = render_template_without_active_template( template, layout_name, locals)
|
59
|
+
template_stack.pop if template_stack
|
60
|
+
result
|
61
|
+
end
|
62
|
+
|
63
|
+
alias_method_chain :render_template, :active_template
|
64
|
+
end
|
65
|
+
|
66
|
+
ActionView::PartialRenderer.class_eval do
|
67
|
+
def render_partial_with_active_template
|
68
|
+
template_stack = @view.controller.respond_to?(:active_template_stack) && @view.controller.active_template_stack
|
69
|
+
template_stack.push(@template) if template_stack
|
70
|
+
result = render_partial_without_active_template
|
71
|
+
template_stack.pop if template_stack
|
72
|
+
result
|
73
|
+
end
|
74
|
+
|
75
|
+
alias_method_chain :render_partial, :active_template
|
76
76
|
end
|
metadata
CHANGED
@@ -1,65 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_parent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Anton Argirov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-12-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.3.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.3.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: jeweler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
description:
|
54
|
+
version: '0'
|
55
|
+
description: This version adds Rails 4 compatibility
|
63
56
|
email: anton.argirov@gmail.com
|
64
57
|
executables: []
|
65
58
|
extensions: []
|
@@ -67,7 +60,7 @@ extra_rdoc_files:
|
|
67
60
|
- LICENSE.txt
|
68
61
|
- README.rdoc
|
69
62
|
files:
|
70
|
-
- .document
|
63
|
+
- ".document"
|
71
64
|
- Gemfile
|
72
65
|
- LICENSE.txt
|
73
66
|
- README.rdoc
|
@@ -80,35 +73,29 @@ files:
|
|
80
73
|
- lib/render_parent/rails3/on_load_action_controller.rb
|
81
74
|
- lib/render_parent/rails3/on_load_action_mailer.rb
|
82
75
|
- lib/render_parent/rails3/on_load_action_view.rb
|
83
|
-
|
84
|
-
- test/test_render_parent.rb
|
85
|
-
homepage: http://redmine.academ.org
|
76
|
+
homepage: http://github.com/anteo/render-parent
|
86
77
|
licenses:
|
87
78
|
- MIT
|
79
|
+
metadata: {}
|
88
80
|
post_install_message:
|
89
81
|
rdoc_options: []
|
90
82
|
require_paths:
|
91
83
|
- lib
|
92
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
85
|
requirements:
|
95
|
-
- -
|
86
|
+
- - ">="
|
96
87
|
- !ruby/object:Gem::Version
|
97
88
|
version: '0'
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
hash: -342591055
|
101
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
90
|
requirements:
|
104
|
-
- -
|
91
|
+
- - ">="
|
105
92
|
- !ruby/object:Gem::Version
|
106
93
|
version: '0'
|
107
94
|
requirements: []
|
108
95
|
rubyforge_project:
|
109
|
-
rubygems_version:
|
96
|
+
rubygems_version: 2.4.6
|
110
97
|
signing_key:
|
111
|
-
specification_version:
|
98
|
+
specification_version: 4
|
112
99
|
summary: Adds Rails "render :parent" helper, which renders template with the same
|
113
100
|
name as current but higher on the view path
|
114
101
|
test_files: []
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'render_parent'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
data/test/test_render_parent.rb
DELETED