Class: DsfrAccessibleSkipLinks::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DsfrAccessibleSkipLinks::Generators::InstallGenerator
- Defined in:
- lib/generators/dsfr_accessible_skip_links/install_generator.rb
Instance Method Summary collapse
- #copy_partial ⇒ Object
- #inject_into_layout ⇒ Object
-
#readme ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#copy_partial ⇒ Object
14 15 16 |
# File 'lib/generators/dsfr_accessible_skip_links/install_generator.rb', line 14 def copy_partial copy_file "_skip_links.html.erb", "app/views/shared/_skip_links.html.erb" end |
#inject_into_layout ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/dsfr_accessible_skip_links/install_generator.rb', line 22 def inject_into_layout return unless [:inject_layout] layout_path = "app/views/layouts/application.html.erb" return unless File.exist?(layout_path) return if layout_contains_render?(layout_path) if layout_has_body_tag?(layout_path) insert_render_after_body(layout_path) else prepend_render_to_layout(layout_path) end end |
#readme ⇒ Object
rubocop:disable Metrics/MethodLength
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/generators/dsfr_accessible_skip_links/install_generator.rb', line 37 def readme say <<~MSG DsfrAccessibleSkipLinks installed successfully! đ Files created: âĸ app/views/shared/_skip_links.html.erb (skip links partial) đ§ Next steps: 1. Add <%= render 'shared/skip_links' %> to your layout file (typically app/views/layouts/application.html.erb) Place it right after the <body> tag for best accessibility. 2. Ensure your layout has these elements with IDs: âĸ #header (main navigation) âĸ #content (main content area)#{' '} âĸ #footer (page footer) đĄ Quick setup option: Run `bin/rails g dsfr_accessible_skip_links:install --inject-layout` to automatically add the render call to your application layout. âšī¸ Helpers are automatically available in all controllers and views. MSG end |