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

Add comment to *.html.erb files that it is possible to dedup the number of these nearly empty files. #67

Open
jho406 opened this issue Jun 16, 2024 · 0 comments

Comments

@jho406
Copy link
Collaborator

jho406 commented Jun 16, 2024

The superglue generator generates a foobar.html.erb for each action, the examples also show usage like this, but its actually easy to dedup these files as they can get overwhelming. We just put them in application for example, instead of posts/index.html.erb, we put them in application/index.html.erb, that will make rails lookup that template higher in the lookup path.

To make this work, we'd need the following in the application controller

  def render(...)
    @active_template_name = _normalize_render(...)[:template]
    super(...)
  end

then change modify the foobar.html.erb files with

<% initial_state = controller.render_to_string(@active_template_name, formats: [:json], locals: local_assigns, layout: true) %>

I think we should

  1. Add a comment inside these generators
  2. Or generate the usual index.html.erb, show.html.erb, edit.html.erb, new.html.erb for the users when running rails superglue:install:web.

Or both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant