Theme Developer's Guide: Template Helpers

Setting the page title

The title helper gets or sets the title for the current page. A single optional string argument may be provided to set a new page title. If no title is set, the title of the current node will be used (if available). Otherwise it will return the name of the current site.

Example: retrieving the title within a layout
<title><%= title %></title>
Example: setting a custom title within a template
<% title "Custom Page Title" %>
Example: extending the current page title
<% title "#{@page.title} - Custom Section" %>

Meta tags

The meta_tags helper inserts meta description, keywords, robots and canonical link tags if provided by the current page/node.

<%= meta_tags %>
<meta name="description" content="Meta description for current page" />
<meta name="keywords" content="meta, keywords, for, current page" />
<meta name="robots" content="noindex, nofollow" />
<link rel="canonical" href="/canonical/path" /> 

Inserting snippets

Snippets can be added to your templates or layouts using the snippet helper. The helper takes a string reference as its only (required) argument, which should match the snippet reference exactly (case-sensitive) as defined in Configuration - Edit Snippets, and returns the HTML snippet content.

<%= snippet "Footer" %>

Node helpers

The node helper returns the current active node. The current node is usually accessible via an instance variable such as @page, but this helper is useful for layouts, custom helpers and similar situations where the node's resource type is not known in advance.

Example: node
<%= node.label %>

You can test whether a node corresponds to the current page using the current_node? helper, which returns true if the given node is the current active node.

Example: current_node?
<%= "Contact Links" unless current_node?(Wheelhouse::Page.get("Contact")) %> 

The home? helper returns true if the current node corresponds to the home page.

Example: home?
<body class="<%= home? ? "home" : "interior" %>">

You can explicitly override the current using the node! helper. Calling this method is generally not necessary for most templates, but can be useful when defining controller actions in your Rails app that should render content from a page defined within Wheelhouse CMS.

Example: node!
<% node!(Wheelhouse::Page.get("Login"))
<%= @page.content %>

Additional Resources