Class: Charming::Generators::LayoutGenerator

Inherits:
AppFileGenerator show all
Defined in:
lib/charming/generators/layout_generator.rb

Overview

LayoutGenerator implements charming generate layout [--style sidebar]. It restores the full app chrome that charming new no longer ships by default: the sidebar layout, the sidebar/content focus ring, the command palette bindings, and the built-in theme registration. Safe to re-run: existing chrome is left untouched.

Constant Summary collapse

STYLES =
%w[sidebar].freeze
USAGE =
"Usage: charming generate layout [--style sidebar]"

Instance Method Summary collapse

Constructor Details

#initialize(name, args, out:, destination:, force: false) ⇒ LayoutGenerator

name is unused (the CLI passes "application"); args may carry --style STYLE.

Raises:



14
15
16
17
18
# File 'lib/charming/generators/layout_generator.rb', line 14

def initialize(name, args, out:, destination:, force: false)
  @style = extract_style(args)
  super
  raise Error, USAGE if args.any?
end

Instance Method Details

#generateObject

Writes the styled application layout, then inserts the controller chrome and the theme registration into the existing app files.



22
23
24
25
26
# File 'lib/charming/generators/layout_generator.rb', line 22

def generate
  write_layout
  insert_controller_chrome
  insert_theme_registration
end