Class: Rolemodel::Turbo::ModalsGenerator
- Inherits:
-
GeneratorBase
- Object
- Rails::Generators::Base
- GeneratorBase
- Rolemodel::Turbo::ModalsGenerator
- Defined in:
- lib/generators/rolemodel/turbo/modals/modals_generator.rb
Instance Method Summary collapse
- #helpers_and_views ⇒ Object
- #inject_into_layout ⇒ Object
- #javascript_entrypoint ⇒ Object
- #register_stimulus_controller ⇒ Object
- #to_panel_or_not_to_panel ⇒ Object
Instance Method Details
#helpers_and_views ⇒ Object
7 8 9 10 11 12 |
# File 'lib/generators/rolemodel/turbo/modals/modals_generator.rb', line 7 def helpers_and_views say 'generating views & helpers', :green directory 'app/helpers' directory 'app/views/layouts' end |
#inject_into_layout ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/rolemodel/turbo/modals/modals_generator.rb', line 25 def inject_into_layout say 'updating application layout', :green inject_into_file 'app/views/layouts/application.html.slim', after: /\bbody.*\n/ do optimize_indentation <<~SLIM, 4 = turbo_frame_tag 'modal' SLIM end end |
#javascript_entrypoint ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/rolemodel/turbo/modals/modals_generator.rb', line 14 def javascript_entrypoint say 'generating & importing javascript files', :green directory 'app/javascript/controllers' directory 'app/javascript/initializers' append_to_file 'app/javascript/application.js', <<~JS import './initializers/frame_missing_handler.js' JS end |
#register_stimulus_controller ⇒ Object
53 54 55 56 57 |
# File 'lib/generators/rolemodel/turbo/modals/modals_generator.rb', line 53 def register_stimulus_controller say 'updating stimulus manifest', :green rails_command 'stimulus:manifest:update' end |
#to_panel_or_not_to_panel ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/rolemodel/turbo/modals/modals_generator.rb', line 35 def to_panel_or_not_to_panel if .panels? say 'Setting Up RoleModel Panel', :green inject_into_file 'app/views/layouts/application.html.slim', after: /\bturbo_frame_tag 'modal'.*\n/ do optimize_indentation <<~SLIM, 4 = turbo_frame_tag 'panel' SLIM end append_to_file application_stylesheet_path, <<~CSS @import '@rolemodel/optics/dist/css/addons/panel'; CSS else remove_file 'app/views/layouts/panel.html.slim' end end |