Make pages editable

Boxcab helps you to structure the content of your page thanks to a handful set of custom tags. Basically, you define the elements of your page that you want to be able to edit through our awesome UI.


It describes your page inside our editor. It's a good practice to put it on top of your Ruby on Rails view.


boxcab_page <options>


Name Type Description
title string title of the page displayed in the back-office
position integer position of the page in the navbar (back-office)


<%= boxcab_page 'My home page', position: 1 %>

<p>My home page view (app/views/welcome/home.html.erb)</p>


It defines an editable element.


boxcab_content <name>, <options>, &block

name should be an underscore string or a symbol. Block is required for the list type.


Name Type Description
label string Text displayed in the back-office
type symbol/string Possible values: string, text, image, list. Default: string
hint string Hint displayed in the back-office
position integer Position of the field in the form
html boolean Enable the Rich Text Editor on the back-office. Only for string/text field types (true|false). Default: false
default string Default value for the field


Simple editable string

<h1><%= boxcab_content 'title', type: 'string', hint: 'Title of the home page' %></h1>

Editable image and text with Rich Text Editor enabled

<div class="hero">
  <% if (background = boxcab_content('background', type: 'image')) != '' %>
    <div class="background">
      <img src="<%= background %>" />
  <% end %>

  <div class="text">
    <%= boxcab_content 'hero', type: 'text', html: true do %>
      <p>Another way to set a default content</p>
    <% end %>

If the type is a list, the block will require an argument which can be useful to know if the current displayed item is the first one for instance. The iterator object has the following methods:

Method Returned type Description
index integer position of the item in the list (0 based)
size integer number of elements in the list
first? boolean true if the current element is the first one in the list
last? boolean true if the current element is the last one in the list
every?(n) boolean true if ((index + 1) mod n) == 0 (and if not first or last)


<div class="gallery">
  <%= boxcab_content 'gallery', label: 'My images', type: 'list', default: 3 do |iterator| %>
    <div class="media <%= 'first-media' if iterator.first? %>">
      <div class="media-left">
        <a href="<%= boxcab_content 'link', type: 'string', default: '#', position: 2 %>">
          <img class="media-object" src="" />

  <% end %>