lib/rails/generators/component/component_generator.rb in view_component-2.24.0 vs lib/rails/generators/component/component_generator.rb in view_component-2.25.0

- old
+ new

@@ -5,17 +5,20 @@ class ComponentGenerator < Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) argument :attributes, type: :array, default: [], banner: "attribute" check_class_collision suffix: "Component" + class_option :inline, type: :boolean, default: false def create_component_file template "component.rb", File.join("app/components", class_path, "#{file_name}_component.rb") end hook_for :test_framework + hook_for :preview, type: :boolean + hook_for :template_engine do |instance, template_engine| instance.invoke template_engine, [instance.name] end private @@ -34,9 +37,13 @@ attributes.map { |attr| "#{attr.name}:" }.join(", ") end def initialize_body attributes.map { |attr| "@#{attr.name} = #{attr.name}" }.join("\n ") + end + + def initialize_call_method_for_inline? + options["inline"] end end end end