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: Generator file name references #644

Merged
merged 1 commit into from
Mar 13, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/generators/stimulus_reflex/stimulus_reflex_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ def execute
end

reflex_entrypoint = Rails.env.test? ? "tmp/app/reflexes" : "app/reflexes"
reflex_src = fetch("/app/reflexes/%file_name%_reflex.rb.tt")
reflex_src = "app/reflexes/%file_name%_reflex.rb.tt"
reflex_path = Rails.root.join(reflex_entrypoint, "#{file_name}_reflex.rb")
stimulus_controller_src = fetch("/app/javascript/controllers/%file_name%_controller.js.tt")
stimulus_controller_src = "app/javascript/controllers/%file_name%_controller.js.tt"
stimulus_controller_path = Rails.root.join(entrypoint, "controllers/#{file_name}_controller.js")

template(reflex_src, reflex_path) unless options[:skip_reflex]
template(stimulus_controller_src, stimulus_controller_path) unless options[:skip_stimulus]

if file_name == "example"
controller_src = fetch("/app/controllers/examples_controller.rb.tt")
controller_src = "app/controllers/examples_controller.rb.tt"
controller_path = Rails.root.join("app/controllers/examples_controller.rb")
template(controller_src, controller_path)

view_src = fetch("/app/views/examples/show.html.erb.tt")
view_src = "app/views/examples/show.html.erb.tt"
view_path = Rails.root.join("app/views/examples/show.html.erb")
template(view_src, view_path)

Expand Down Expand Up @@ -83,10 +83,4 @@ def execute
end
end
end

private

def fetch(file)
source_paths.first + file
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class <%= class_name %>Reflex < ApplicationReflex
<%- actions.each do |action| -%>
def <%= action %>
end
<%= "\n" unless action == actions.last -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julianrubisch did you remove this by accident?
Screenshot 2023-03-13 at 15 19 35

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no, because it resulted in a dangling indentation for the last end.

might have to have another look at that

<%- end -%>
<%- end -%>
end