-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support Parameterised Layouts #192
Conversation
@@ -60,5 +44,30 @@ def self.included(klass) | |||
|
|||
klass.extend(Interface) | |||
end | |||
|
|||
def render(view_context, *args, **kwargs, &block) | |||
if @_context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If @_context
is set, we're already rendering and this should not be treated as an external call to render the layout. It should do the normal render
behaviour instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably define a method for this, e.g.
def rendering?
!!@_context
end
output = view_context.capture(&block) | ||
end | ||
|
||
unsafe_raw output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return nil
after pushing with unsafe_raw
.
Hi! I like this change. I needed something like this in the past. However, it appears to have broken this kind of code: class ApplicationLayout < Phlex::HTML
include Phlex::Rails::Layout
def view_template
html do
body do
render partial: "tracking" # boom
end
end
end
end It raises:
|
With this change, you will be able to use parameterised layouts, e.g.
For more details on why you might want to do this, see https://jardo.dev/adding-parameterized-layouts-to-phlex-rails
Todo