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

PreviewExample

Represents a single, annotated example method within a ViewComponent preview class.

Attributes

.id

Unique ID for the example

Type: String
.label

Label for the example, used in navigation

Type: String
.file_path

Full filesystem path to the parent preview class file

Type: Pathname
.url_path

URL of the preview example in Lookbook

Type: String
.source

The source code for the example

Type: String
.source_lang

Hash of information about the source language (Ruby or HTML/ERB, depending on whether the example uses a preview template)

Type: Hash
.type

The entity type. Returns :example

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_example.tags(<tag_type?>)
<tag_type?>

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

Type: Symbol
<ul id="todo-list">
  <% preview_example.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_example.tag(<tag_type?>)
<tag_type?>

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

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