Skip to content
David Van Der Beek edited this page Mar 31, 2015 · 2 revisions

Text snippets are small chunks of user-editable content that can be re-used in various places in your host app. They can be created in the Text Snippets section of the Admin Dashboard.

Storytime takes the position that complex page structure should not live in the database. If you need a complex page that requires heavy HTML/CSS, but still want to the actual content be editable in the CMS, you should use a text snippet.

Snippets can be accessed through the storytime_snippet method. Content returned from that method is marked HTML-safe, allowing you to include simple HTML content in your snippets.

The following example shows two snippets named "first-column-text" and "second-column-text" being accessed through the storytime_snippet method:

<h1>My Home Page</h1>
<div class="row">
  <div class="col-md-6"><%= storytime_snippet("first-column-text") %></div>
  <div class="col-md-6"><%= storytime_snippet("second-column-text") %></div>
</div>

When a storytime user who has permission to edit Snippets is logged in, the snippets will be clickable when viewing the site. Clicking on the snippet will open up the edit view for that snippet so you can easily edit content without leaving the page.