render_with_missing_template 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,8 +25,14 @@ app/controllers/test_controller.rb
25
25
  # Renders template layouts/default/index if tests/index is missing
26
26
  render :if_missing => {:template => "layouts/default/index"}
27
27
  end
28
+
29
+ def index
30
+ # Renders template layouts/default/index if tests/index is missing inside layout 'nowhere'. Render options are merged with default options.
31
+ # Not shure that it is good strategy to merge. May be, option is required.
32
+ render :layout => 'nowhere', :if_missing => {:template => "layouts/default/index"}
33
+ end
28
34
 
29
35
  app/views/index.html.erb
30
36
 
31
37
  <!-- Raises TemplateMissing because there is no :if_missing option here. -->
32
- <%= render :partial => "navigation2" %>
38
+ <%= render :partial => "navigation2" %>
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ begin
13
13
  gem.summary = "Extends rails render method to accept default template when expected template is missing"
14
14
  gem.description = "Extends rails render method to render default template when expected template is missing"
15
15
  gem.files = FileList["[A-Z]*", "lib/**/*"]
16
- gem.version = "0.0.3"
16
+ gem.version = "0.0.4"
17
17
  gem.email = "gzigzigzeo@gmail.com"
18
18
  gem.authors = ["Victor Sokolov"]
19
19
  gem.homepage = "http://github.com/gzigzigzeo/render_with_missing_template"
@@ -29,6 +29,7 @@ module RenderWithMissingTemplate
29
29
  render_without_defaults(options.merge(:nested => true))
30
30
  rescue MissingTemplateContainer => e
31
31
  unless defaults == false
32
+ defaults = options.merge(defaults)
32
33
  render_without_defaults(defaults)
33
34
  else
34
35
  render_without_defaults(:nothing => true)
@@ -25,7 +25,6 @@ describe ApplicationController do
25
25
  lambda { get :error_in_regular }.should raise_error
26
26
  end
27
27
 
28
-
29
28
  it "should raise error if it raises in nested template" do
30
29
  lambda { get :nested }.should raise_error
31
30
  end
@@ -33,4 +32,10 @@ describe ApplicationController do
33
32
  it "should raise error if it raises in nested missing template" do
34
33
  lambda { get :all_missing, :if_missing => {:action => :nested} }.should raise_error
35
34
  end
35
+
36
+ it "should raise pass :layout and :format to action controller" do
37
+ get :missing_with_template_and_layout
38
+ response.should render_template('iframe/iframe')
39
+ response.body.should =~ /IFRAME/
40
+ end
36
41
  end
@@ -22,5 +22,9 @@ class ApplicationController < ActionController::Base
22
22
  end
23
23
 
24
24
  def nested
25
- end
25
+ end
26
+
27
+ def missing_with_template_and_layout
28
+ render :content_type => "text/html", :format => :html, :layout => 'iframe', :if_missing => {:template => "iframe/iframe"}
29
+ end
26
30
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_with_missing_template
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Victor Sokolov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-08 00:00:00 +03:00
18
+ date: 2010-12-21 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency