🚨 You are viewing the legacy v1.x docs. See the new v2 documentation →
v1.5.5

Preview

Represents an annotated ViewComponent preview class.

Attributes

.id

Unique ID for the preview

Type: String
.label

Label for the preview, used in navigation

Type: String
.path

Unique preview reference path.

Type: String
.url_path

URL path of the preview

Type: String
.file_path

Absolute filesystem path to the preview class file

Type: Pathname
.examples

Array of all the preview examples defined in the preview class

Type: Array
.components

Array of all the components used in the preview - usually just one!

Type: Array
.component

The first (and normally only) component used in the preview

Type: Component
.type

The entity type. Returns :preview

Type: Symbol

Methods

.tags

Returns an array of tag objects representing all tags that have been applied of the specified type.

If no tag type is provided then all tags are returned.

preview.tags(<tag_type?>)
<tag_type?>

Optional tag type to filter by - e.g. :todo

Type: Symbol
<ul id="todo-list">
  <% preview.tags(:todo).each do |todo| %>
    <li><%= todo.task %></li>
  <% end %>
</ul>

.tag

Returns the first Tag of type <tag_type> that has been applied.

preview.tag(<tag_type?>)
<tag_type?>

Optional tag type to filter by - e.g. :status

Type: Symbol
<p>Preview status: "<%= preview.tag(:status).label %>"</p>