User Guide / Pages

Variables & Helpers

Pages are rendered as an ERB templates before being (optionally) processed as markdown, and Lookbook makes a number of variables and helpers available that can be used to add dynamic content.

Variables

All pages have the following variables available for use in the page template:

page PageEntity

Object representing the current page

next_page PageEntity

Object representing the next page (if available)

previous_page PageEntity

Object representing the previous page (if available)

pages Array<PageEntity>

Array of all available pages

Page objects have access to the frontmatter variables for that page:

The page title is <%= page.title %>
Our brand color hex value is <%= page.data[:brand_colors][:red] %>

Helpers

The following helpers are available to use in your page templates.

embed (preview, scenario = nil, **opts)

Render a 'live' embed of a component preview.

If no scenario name is provided then the default (first) preview scenario will be rendered in the embed.

Arguments:

preview String

Name of the preview class to embed

scenario String

Example method name

opts Hash

Options hash

User Guide

Extending Lookbook

API

Elsewhere