module Lookbook

def add_input_type(name, partial_path, opts = {})

Parameters:
  • opts (Hash) -- Set of default options to be passed to the input. Any supplied param options will override these values
  • partial_path (String) -- Path to the partial template used to render the input
  • name (Symbol) -- Unique input type name
def add_input_type(name, partial_path, opts = {})
  Engine.inputs.add_input(name, partial_path, opts)
end

def add_panel(name, partial_path, opts = {})

Options Hash: (**opts)
  • :locals (Hash) -- A hash of local variables that will be passed to the panel when it is rendered
  • :copy (String) -- If present, the panel will display a copy button that copies the value of this property to the clipboard when clicked
  • :disabled (Boolean) -- Disabled tabs are still accessible but are greyed out in the UI
  • :hotkey (String) -- [Keyboard shortcut](https://alpinejs.dev/directives/on#keyboard-events) used to switch to the panel
  • :label (String) -- The text to be displayed in the panel tab

Parameters:
  • opts (Hash) -- Set of panel options
  • partial_path (String) -- Path to the partial template used to render the panel
  • name (Symbol, String) -- Unique panel name

Other tags:
    Example: :ruby -
def add_panel(name, partial_path, opts = {})
  Engine.panels.add_panel(name, partial_path, opts)
end

def add_tag(name, args = nil, &block)

Other tags:
    Yield: - The custom tag instance

Parameters:
  • args (Array) -- Array of argument names
  • name (Symbol, String) -- Tag name
def add_tag(name, args = nil, &block)
  Engine.tags.add_tag(name, {
    named_args: args.to_a,
    after_parse: block
  })
end

def after_change(&block)

Other tags:
    Yield: - Lookbook app and hash of files changed, added & removed
def after_change(&block)
  Engine.hooks.add_hook(:after_change, block)
end

def after_initialize(&block)

Other tags:
    Yield: - Lookbook app

Other tags:
    Example: :ruby -
def after_initialize(&block)
  Engine.hooks.add_hook(:after_initialize, block)
end

def before_exit(&block)

Other tags:
    Yield: - Lookbook app
def before_exit(&block)
  Engine.hooks.add_hook(:before_exit, block)
end

def broadcast(event_name, data = {})

Other tags:
    Api: - private
def broadcast(event_name, data = {})
  Engine.websocket&.broadcast(event_name.to_s, data)
end

def config

Returns:
  • (ConfigStore) - The config store object

Other tags:
    Example: :ruby -
def config
  @_config ||= ConfigStore.init_from_config
end

def configure

Other tags:
    Api: - private
def configure
  yield(config)
end

def data

Returns:
  • (Store) - The global data store instance
def data
  @_data ||= Store.new
end

def data=(new_data)

Returns:
  • (Store) - The global data store instance

Parameters:
  • new_data (Hash) -- Hash of data to store
def data=(new_data)
  @_data = Store.new(new_data)
end

def debug_data

Other tags:
    Api: - private
def debug_data
  {
    version: version,
    env: Rails.env.to_s,
    config: [
      config.to_h,
      {
        dependencies: {
          actioncable: Engine.runtime_context.actioncable_installed?,
          listen: Engine.runtime_context.listen_installed?,
          view_component: config.using_view_component
        }
      },
      {panels: Engine.panels.to_h.reject { |k, v| v[:system] }},
      {inputs: Engine.inputs.to_h.reject { |k, v| v[:system] }},
      {tags: Engine.tags.to_h.reject { |k, v| v[:system] }}
    ].inject(:merge)
  }
end

def engine

Other tags:
    Api: - private
def engine
  Engine
end

def logger

Other tags:
    Api: - private
def logger
  @_logger ||= if Rails.logger.present? && config.log_use_rails_logger
    Rails.logger
  else
    logger = Logger.new($stdout)
    logger.level = config.log_level
    logger
  end
end

def pages

Returns:
  • (Array) - Array of page entities
def pages
  Engine.pages.to_a
end

def previews

Returns:
  • (Array) - Array of preview entities
def previews
  Engine.previews.to_a
end

def remove_panel(name)

Parameters:
  • name (Symbol, String) -- Name of target panel

Other tags:
    Example: :ruby -
def remove_panel(name)
  Engine.panels.remove_panel(name)
end

def update_panel(name, opts)

Options Hash: (**opts)
  • :locals (Hash) -- A hash of local variables that will be passed to the panel when it is rendered
  • :copy (String) -- If present, the panel will display a copy button that copies the value of this property to the clipboard when clicked
  • :disabled (Boolean) -- Disabled tabs are still accessible but are greyed out in the UI
  • :hotkey (String) -- [Keyboard shortcut](https://alpinejs.dev/directives/on#keyboard-events) used to switch to the panel
  • :label (String) -- The text to be displayed in the panel tab

Parameters:
  • opts (Hash) -- Set of panel options
  • name (Symbol, String) -- Name of target panel

Other tags:
    Example: :ruby -
def update_panel(name, opts)
  Engine.panels.update_panel(name, opts)
end

def version

Returns:
  • (String) - Version number string

Other tags:
    Example: :erb -
def version
  Lookbook::VERSION
end