Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with templates that don't have a virtual_path #19

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/props_template/layout_patch.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Props
module LayoutPatch
def render_template(view, template, layout_name, locals)
unless view.respond_to? :active_template_virtual_path
if !view.respond_to?(:active_template_virtual_path) && template.respond_to?(:virtual_path)
view.instance_eval <<~RUBY, __FILE__, __LINE__ + 1
def active_template_virtual_path; "#{template.virtual_path}";end
RUBY
Expand Down
10 changes: 10 additions & 0 deletions spec/layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ def self.controller_path
expect(json.strip).to eql('{"success":"ok"}')
end
end

it "allows rendering of templates that do not have a virtual_path" do
view_path = File.join(File.dirname(__FILE__), "./fixtures")
controller = TestController.new
controller.prepend_view_path(view_path)

expect(
controller.render_to_string(plain: "some text")
).to eql "some text"
end
end
Loading