You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if a before_callback is the best path forward. For example:
before_action :use_superglue_defaults
We would need to override the default_render and render.
default_render
checks first if the template exists (implicitly using the request.format, if it does, then call render). If the request.format.html? is true, then this breaks, we need to override so that NOT having a html.erb file is acceptable. The override behavior probably should be: if the request format is html AND the template file for the json version exist && @_use_superglue_defaults is true, then call render, else super.
render
needs to be changed so that its rendering a template explicitly. Something like application/superglue.html.erb with the same content as the erb snipped above.. The override behavior should
if the request format is html AND @_user_superglue_defaults is true, then render_to_string the json version of the template, that that content and inject it to a @superglue_initial_page_state and set that as the initial_page_state in the application/superglue.html.erb.
Somehow make the template configurable.
I also want to make sure that the below is possible, a locally defined index.html.erb should override a superglue.html.erb:
context
This issue is related to thoughtbot/superglue#67 and thoughtbot/superglue#47.
Since superglue_rails was extracted from the original superglue monorepo, i'll do a quick recap:
In a typical superglue app, the
html.erb
files for every action are virtually the same, and looks like this:Goal
I would like for
superglue_rails
to add a way to modify the rendering (implicit and explicit render) behavior so that we can omit thehtml.erb
files:I'm wondering if a
before_callback
is the best path forward. For example:We would need to override the
default_render
andrender
.default_render
checks first if the template exists (implicitly using the
request.format
, if it does, then callrender
). If therequest.format.html?
is true, then this breaks, we need to override so that NOT having ahtml.erb
file is acceptable. The override behavior probably should be: if the request format is html AND the template file for thejson
version exist &&@_use_superglue_defaults
is true, then call render, elsesuper
.render
needs to be changed so that its rendering a template explicitly. Something like
application/superglue.html.erb
with the same content as the erb snipped above.. The override behavior should@_user_superglue_defaults
is true, thenrender_to_string
thejson
version of the template, that that content and inject it to a@superglue_initial_page_state
and set that as theinitial_page_state
in theapplication/superglue.html.erb
.I also want to make sure that the below is possible, a locally defined
index.html.erb
should override asuperglue.html.erb
:The text was updated successfully, but these errors were encountered: