Class: Hibiki::Rails::Generators::IslandGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Hibiki::Rails::Generators::IslandGenerator
- Includes:
- GeneratorHelpers
- Defined in:
- lib/generators/hibiki/rails/island/island_generator.rb
Overview
The island shape — the packaged generic "hibiki" controller drives the island, so there is NO per-component JS: a channel and a self-contained view partial stamped through Hibiki::Rails::Helpers (never raw data-hibiki-* attributes — that contract is private to the gem). Emits the same working mini-example as the stimulus shape, over the same Turbo-broadcast transport.
Needs the one-time wiring from hibiki:rails:install (the register line + the Helpers include); post_install hints when it's missing.
Constant Summary
Constants included from GeneratorHelpers
GeneratorHelpers::APPLICATION_HELPER, GeneratorHelpers::IMPORTMAP, GeneratorHelpers::INDEX_JS, GeneratorHelpers::REGISTER_FRAGMENT, GeneratorHelpers::SHIM
Instance Method Summary collapse
Instance Method Details
#create_channel ⇒ Object
29 30 31 |
# File 'lib/generators/hibiki/rails/island/island_generator.rb', line 29 def create_channel template "channel.rb.tt", "app/channels/#{file_path}_channel.rb" end |
#create_views ⇒ Object
33 34 35 36 |
# File 'lib/generators/hibiki/rails/island/island_generator.rb', line 33 def create_views template "island.html.erb.tt", "app/views/#{view_dir}/_#{file_name}.html.erb" template "display.html.erb.tt", "app/views/#{view_dir}/_#{file_name}_display.html.erb" end |
#post_install ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/hibiki/rails/island/island_generator.rb', line 38 def post_install say <<~MSG Render it from any page: <%= render "#{view_dir}/#{file_name}" %> MSG wiring_hint end |