User Guide / Components

Using with Phlex

Phlex is “a framework for building fast, reusable, testable views in pure Ruby”.

Whilst Phlex does not have a concept of a ‘component’ as such but its views can effectively be used to fulfill the same role in an application.

Lookbook enables you to preview Phlex views in isolation for development and testing.

See the Phlex docs for setup and usage instructions:

Locating views

Lookbook assumes that Phlex view files will be stored in the app/views directory.

If that is not the case, you will need to add your Phlex view path to the component_paths config option:

config.lookbook.component_paths << "path/to/phlex/views"

Rendering in previews

Phlex components are rendered in preview classes using the render method:

# test/components/previews/article_view_preview.rb
class ArticleViewPreview < Lookbook::Preview
  def default

  def with_args
    render "This is a title") do
      "This is the body"

User Guide

Extending Lookbook