PreviewExample
Represents a single, annotated example method within a ViewComponent preview class.
Attributes
.id | Unique ID for the example |
.label | Label for the example, used in navigation |
.file_path | Full filesystem path to the parent preview class file |
.url_path | URL of the preview example in Lookbook |
.source | The source code for the example |
.source_lang | Hash of information about the source language (Ruby or HTML/ERB, depending on whether the example uses a preview template) |
.type | The entity type. Returns |
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. |
<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. |
<p>Preview status: "<%= preview_example.tag(:status).label %>"</p>