Cheat Sheet

The cheat sheet is still under construction, but here is a first part.

Page properties

---
title: Page title
layout: default
---

Output page properties in layout and content files:

{{ page.title }}
{{ page.layout }}

Allowed file extensions
htm, html, markdown, md, rss, rst, textile, txt, xml

Homepage
index.md

Content segments

--- default ---
--- left ---
--- right ---

Output content segments in layout files:

{{ content.default }}
{{ content.left }}
{{ content.right }}

Event Listeners

Name Description
ContentRenderedEvent Triggered after content was rendered
LayoutRenderedEvent Triggered after layout was rendered
PluginsInitializedEvent Triggered after plugins where initialized
RenderLayoutEvent Triggered when layout is rendered
RenderPageEvent Triggered when page is rendered
RenderSegmentEvent Triggered when segment is rendered
ResponseEmittedEvent Triggered after HTTP Response was emitted
ResponseGeneratedEvent Triggered after HTTP Response was generated
TranslatorInitializedEvent Triggered after translator was initialized
TwigInitializedEvent Triggered after twig was initialized

Twig Filters

Name Description
filesize Returns file size in a human readable format (B, KB, MB, GB, TB, PB).
find Find items of a traversable list by one or more selectors. Selectors are simple strings of text that specify fields and values. They are logical AND-connected and given as variadic arguments. Selectors in Herbie are loosely based around the idea and syntax of CSS attribute selectors. A selector can be one of the following: <table class="pure-table pure-table-horizontal"> <tr><td style='width:5%'>=</td><td>Equal to</td></tr> <tr><td>!=</td><td>Not equal to</td></tr> <tr><td>&lt;</td><td>Less than</td></tr> <tr><td>&gt;</td><td>Greater than</td></tr> <tr><td>&lt;=</td><td>Less than or equal to</td></tr> <tr><td>&gt;=</td><td>Greater than or equal to</td></tr> <tr><td>*=</td><td>Contains phrase/text</td></tr> <tr><td>~=</td><td>Contains all words</td></tr> <tr><td>^=</td><td>Starts with phrase/text</td></tr> <tr><td>$=</td><td>Ends with phrase/text</td></tr> <tr><td>&</td><td>Bitwise AND</td></tr> </table>
slugify Returns a string slug for using as an URL segment.
strftime Formats a local time/date according to locale settings. This is a wrapper for the same-named PHP function.
visible Filters the page tree by visible and active page items.

Twig Globals

Name Description
baseUrl The base url.
config The configurations as Config object.
page Page wide variables.
route The requested route to a page, i.e. `documentation/variables`.
routeParams The requested route params.
site Project-wide variables.
theme The configured theme.

Twig Functions

Name Description
abs_url Returns the absolute URL for a given route.
add_css Adds a CSS asset to the HTML page.
add_js Adds a JavaScript asset to the HTML page.
css_classes Returns a string with CSS classes, to be used within an HTML attribute, for example the html or body tag. This allows to address any page, theme, layout or language via CSS selector. Such a string looks like: "page-blog theme-default layout-blog language-en"
file Returns a link to a file with additional info like file type and size.
image Returns an image markup tag. No image processing is performed.
menu_ascii_tree Creates a text based (=ascii) tree of all pages. All parameters are optional and passed as named parameters.
menu_breadcrumb Returns a breadcrumb path for the given page. All parameters are passed as an associative array.
menu_list Returns a paginated list of page items with links to the previous and next page. For the paging the GET parameter "page" is used.
menu_pager Creates a pagination with links to the previous an next page within the current page branch. All parameters are optional and passed as named parameters (see twig).
menu_sitemap Creates a simple sitemap for all pages of the website based on an unordered list. All parameters are optional and passed as named parameters.
menu_tree Returns an HTML menu as unordered list. All parameters are optional and passed as named parameters.
output_css Outputs the CSS assets for a given group.
output_js Outputs the JavaScript assets for a given group.
page_link Returns a HTML link with label and attributes for a given route or an URL.
page_title Returns the SEO optimized page title of the website. All parameters are optional and passed as named parameters.
snippet Includes a snippet and outputs the rendered content of that file. Automatic escaping is disabled for all escaping strategies.
translate Translates a string according to the configuration and locale settings.
url Returns the relative URL to a given route.

Twig Tests

Name Description
readable Tests if the given alias or path exists and is readable.
writable Tests if the given alias or path exists and is writable.

Console Commands

Name Description
clear-files The clear-files command deletes asset, cache and log files from several directories.

Plugins

Name Description
Dummy This system plugin shows all possibilities how to extend Herbie. The plugin is helpful during development, but should be disabled in productive environment.
Imagine This system plugin integrates Imagine, an OOP image editing library, into your Herbie website. Thanks to Imagine, you can edit images directly and apply ready-made filters and effects to them.
Markdown This system plugin can be used to parse markdown-formatted texts. Internally, the plugin is responsible for parsing markdown-formatted page content.
Simplecontact Simplecontact adds a simple contact form with name, email and message fields to a website created with Herbie.
Simplesearch Simplesearch adds a simple but effective search functionality to a website created with Herbie.
Textile This system plugin can be used to parse textile-formatted texts. Internally, the plugin is responsible for parsing textile-formatted page content.
Twig Core This system plugin provides basic Twig filters, functions and tests that are useful for creating a web project with Herbie.
Twig Plus This system plugin provides extended Twig functions that are useful for creating a web project with Herbie.
reStructuredText This system plugin can be used to parse reStructuredText-formatted texts. Internally, the plugin is responsible for parsing reStructuredText-formatted page content.