Is there a way, to conditionally change the layout for a particular view? Or to render in in a layout/without a layout based on… request or whatever logic comes before the rendering I guess.
Here is an example:
module Main
module Views
module Register
class New < Main::View
end
end
end
end
module Main
module Actions
module Register
class New < Main::Action
def handle(request, response)
end
end
end
end
end
The view is rendered from this action. No extra logic. It is normally rendered when entering /register
endpoint. However I also have a point in my /
path, where user can click “REGISTER” not in the navbar, but inside some hero section. Then HTMX makes a request to /register
and replaces part of the page content with the rendered template. However it is rendered with the whole layout. So I need to change the layout before rendering, instead of at config level. HTMX sends some extra headers that I could use to determine whether I should use the layout or not.
Right now I see no way of doing this. Searched the documentation and checked the view object config, but there is not way of changing it (without interfering with the internals in meta way).
Is there an option of doing it? Or do I just need two views? Decide which view to render based on a header, and the only difference between them would be config.layout = false
in one of them.