Skip to content

Kits: rendering a namespaced component from Phlex #316

@nimmolo

Description

@nimmolo

I'm using Kits. I have module Components, which extends Phlex::Kit, defined in config/initializers/phlex.rb.

My Panel component includes Components and it needs to render some namespaced sub-components like Panel::Heading and Panel::Body, etc. It seems that because of the namespacing, i can't use the shorter Kits syntax.

I'm getting NoMethodError for Heading in all these cases. None of the following work:

class Components::Panel < Components::Base
  include Components

  prop :heading, _Nilable(String), default: nil
  ...

  def render_heading
    # Panel::Heading(...) <- doesn't work
    # Heading(...)        <- doesn't work
    # Panel.Heading(...)  <- doesn't work

To be clear, this file exists at components/panel/heading.rb

class Components::Panel::Heading < Components::Base
  # include Components <- doesn't work
  ...

How do i render these sub components from Panel without calling render? The docs aren't explicit on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions