module Line::Message::Builder::Flex::HasPartial

The HasPartial module provides functionality for Flex Message components (like Box, Bubble) to render reusable “partials”. Partials are defined by creating classes that inherit from Partial.

Including this module into a component class gives it the partial! method.

Example

# Define a reusable partial
class MyButtonPartial < Line::Message::Builder::Flex::Partial
  def call
    # +button+ method is available from the context (e.g., a Box)
    button style: :primary do
      # +data+ and +label+ are available from <code>context.assigns</code>
      postback data, label: label
    end
  end
end

# Use the partial within a Box component
Line::Message::Builder.with do
  flex do
    bubble do
      body do
        partial! MyButtonPartial, label: "Action", data: "action=do_something"
      end
    end
  end
end

See also: