Module: Charming::Generators::AppGenerator::ViewTemplate
- Included in:
- Charming::Generators::AppGenerator
- Defined in:
- lib/charming/generators/app_generator/view_template.rb
Instance Method Summary collapse
- #application ⇒ Object
- #executable ⇒ Object
- #root_file ⇒ Object
- #version ⇒ Object
- #view ⇒ Object
- #view_helpers ⇒ Object
Instance Method Details
#application ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 41 def application %(# frozen_string_literal: true module #{name.class_name} class Application < Charming::Application Charming::UI::Theme.built_in_names.each do |theme_name| theme theme_name.to_sym, built_in: theme_name end default_theme :phosphor end end ) end |
#executable ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 7 def executable %(#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" require "#{name.snake_name}" Charming.run(#{name.class_name}::Application.new) ) end |
#root_file ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 18 def root_file %(# frozen_string_literal: true require "charming" require "zeitwerk" module #{name.class_name} end loader = Zeitwerk::Loader.new loader.tag = "#{name.snake_name}" loader.inflector.inflect("version" => "VERSION") loader.push_dir(File.expand_path("#{name.snake_name}", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/models", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/components", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/views", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/controllers", __dir__), namespace: #{name.class_name}) loader.setup require_relative "../config/routes" ) end |
#version ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 56 def version %(# frozen_string_literal: true module #{name.class_name} VERSION = "0.1.0" end ) end |
#view ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 65 def view %(# frozen_string_literal: true module #{name.class_name} class HomeView < Charming::View def render app_frame end #{view_helpers} end end ) end |
#view_helpers ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 79 def view_helpers %( private def app_frame render_component AppFrameComponent.new(title: home.title, theme: theme) end) end |