summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy.asynk.ch>2026-02-14 19:10:36 +0100
committerJérémy Zurcher <jeremy.asynk.ch>2026-02-14 19:10:36 +0100
commit21947338ffd078905afa07d7b3fdf9fee45cc08a (patch)
tree0127ec34368048a005025c0704c788057fffe3b8
parentdbe5078f445fb25da2e055ba7a42e4bd56cd7fb3 (diff)
downloadzorglub-21947338ffd078905afa07d7b3fdf9fee45cc08a.zip
zorglub-21947338ffd078905afa07d7b3fdf9fee45cc08a.tar.gz
may override view in partial call
-rw-r--r--lib/zorglub/node.rb2
-rw-r--r--spec/node_spec.rb4
-rw-r--r--spec/spec_helper.rb2
3 files changed, 6 insertions, 2 deletions
diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb
index 405faac..87ed6a8 100644
--- a/lib/zorglub/node.rb
+++ b/lib/zorglub/node.rb
@@ -275,7 +275,7 @@ module Zorglub
@request = @parent ? @parent.request : Rack::Request.new(env)
@response = @parent ? @parent.response : Rack::Response.new
- @view = r(meth)
+ @view = options[:view] || r(meth)
@partial = options[:partial] || false
@layout = (options[:partial] ? nil : self.class.layout)
diff --git a/spec/node_spec.rb b/spec/node_spec.rb
index 3aaec55..b3cb97c 100644
--- a/spec/node_spec.rb
+++ b/spec/node_spec.rb
@@ -176,6 +176,10 @@ describe Zorglub do
expect(Node0.partial(:other_view)).to eq 'partial_content'
end
+ it 'partial may override the view' do
+ expect(Node0.partial(:do_partial, 1, 2, view: Node0.r(:do_render))).to eq 'do_render'
+ end
+
it 'partial with hooks should be default' do
Node3.before = 0
Node3.after = 0
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b81f0cf..c5d55fa 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -33,7 +33,7 @@ RENDER_PROC = proc { |_path, obj|
when :view
['view_content', 'text/view']
when :partial
- ['partial_content', 'text/partial']
+ [obj.view =~ /do_render/ ? 'do_render' : 'partial_content', 'text/partial']
else
raise Exception.new
end