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 " DsfrAccessibleSkipLinks installed successfully!\n\n \u{1F4C1} Files created:\n \u2022 app/views/shared/_skip_links.html.erb (skip links partial)\n\n \u{1F527} Next steps:\n 1. Add <%= render 'shared/skip_links' %> to your layout file (typically app/views/layouts/application.html.erb)\n Place it right after the <body> tag for best accessibility.\n\n 2. Ensure your layout has these elements with IDs:\n \u2022 #header (main navigation)\n \u2022 #content (main content area)\#{' '}\n \u2022 #footer (page footer)\n\n \u{1F4A1} Quick setup option:\n Run `bin/rails g dsfr_accessible_skip_links:install --inject-layout` to automatically\n add the render call to your application layout.\n\n \u2139\uFE0F Helpers are automatically available in all controllers and views.\n MSG\nend\n" |