diff --git a/spec/blueprint/html/components_registration_spec.cr b/spec/blueprint/html/components_registration_spec.cr deleted file mode 100644 index fd20c43..0000000 --- a/spec/blueprint/html/components_registration_spec.cr +++ /dev/null @@ -1,81 +0,0 @@ -require "../../spec_helper" - -private class ExamplePage - include Blueprint::HTML - - register_component :component_with_block, ComponentWithBlock - register_component :component_without_block, ComponentWithoutBlock, block: false - register_component :component_with_optional_block, ComponentWithOptionalBlock, block: :optional - - private def blueprint - component_with_block do - "Component with required block" - end - - component_without_block - - component_with_optional_block do - "Component with optional block" - end - - component_with_optional_block - end -end - -private class ComponentWithBlock - include Blueprint::HTML - - private def blueprint(&) - div id: "required-block" do - yield - end - end -end - -private class ComponentWithoutBlock - include Blueprint::HTML - - private def blueprint - h1 { "Component without block" } - end -end - -private class ComponentWithOptionalBlock - include Blueprint::HTML - - private def blueprint(&) - div id: "optional-block" do - yield - end - end -end - -describe "components registration" do - it "allows component helper definition" do - page = ExamplePage.new - expected_html = normalize_html <<-HTML -
Component with required block
- HTML - - page.to_s.should contain expected_html - end - - it "allows component helper definition without required block" do - page = ExamplePage.new - expected_html = normalize_html <<-HTML -

Component without block

- HTML - - page.to_s.should contain expected_html - end - - it "allows component helper definition with optional block" do - page = ExamplePage.new - expected_html = normalize_html <<-HTML -
Component with optional block
-
- HTML - - page.to_s.should contain expected_html - end -end diff --git a/src/blueprint/html.cr b/src/blueprint/html.cr index cba4796..f8e806e 100644 --- a/src/blueprint/html.cr +++ b/src/blueprint/html.cr @@ -9,7 +9,6 @@ module Blueprint::HTML include Blueprint::HTML::AttributesHandler include Blueprint::HTML::BlockRenderer include Blueprint::HTML::BufferAppender - include Blueprint::HTML::ComponentRegistrar include Blueprint::HTML::ElementRegistrar include Blueprint::HTML::ElementRenderer include Blueprint::HTML::Helpers diff --git a/src/blueprint/html/component_registrar.cr b/src/blueprint/html/component_registrar.cr deleted file mode 100644 index c0df21d..0000000 --- a/src/blueprint/html/component_registrar.cr +++ /dev/null @@ -1,21 +0,0 @@ -module Blueprint::HTML::ComponentRegistrar - macro register_component(helper_method, component_class, block = true) - {% if block %} - private def {{helper_method.id}}(*args, **kwargs, &) : Nil - render {{component_class}}.new(*args, **kwargs) do |component| - yield component - end - end - - {% if block == :optional %} - private def {{helper_method.id}}(*args, **kwargs) : Nil - render({{component_class}}.new(*args, **kwargs)) {} - end - {% end %} - {% else %} - private def {{helper_method.id}}(*args, **kwargs) : Nil - render {{component_class}}.new(*args, **kwargs) - end - {% end %} - end -end