Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (50 sloc) 3.25 KB
title: Helpers
area: docs
section: templates
## Built-in Helpers
Assemble includes the [handlebars-helpers][handlebars-helpers] library as a dependency, so more than **100 Handlebars helpers** from that library are available by default.
### Also see [Custom Helpers][custom-helpers] | [grunt-init-assemble-helper]( | [grunt-init-assemble-helper]( →
### Helpers created for Assemble
Most helpers from [handlebars-helpers][] can be used with any Handlebars project, but a handful of helpers were created specifically for Assemble, including:
* **dirname**: Returns the absolute path to the given file/directory. Would return: `path/to/`. Usage: `\{{dirname [path]}}`
* **pagename**: Returns the full-name of a given file. Would return: ``. Usage: `\{{filename "docs/"}}`
* **filename**: Can be used as an alternate for `pagename`.
* **basename**: Returns the basename of a given file. Would return: `variables` Usage: `\{{base "docs/"}}`
* **extension**: Returns the extension of a given file. Would return: `.md` Usage: `\{{extension "docs/"}}`
* **ext**: Can be used as an alternate for`extension`.
* **relative**: Returns the derived relative path from file A to file B. Usage: `\{{relative [from] [to]}}`. This can also be used with `page` and `pages`.
* **markdown**: Markdown block helper enables writing markdown inside HTML and then renders the markdown as HTML inline with the rest of the page. Usage: `\{{#markdown}}\{{/markdown}}`
* **md**: Markdown helper used to read in a file and inject the rendered markdown into the HTML. Usage: `\{{md [path]}}`
* **embed**: Embeds code from an external file as preformatted text. The first parameter requires a path to the file you want to embed. The second optional parameter allows forcing syntax highlighting for a specific language. Usage: `\{{embed 'path/to/file.js'}}` or `\{{embed 'path/to/file.hbs' 'html'}}`
* **jsFiddle**: Embed a jsFiddle, second parameter sets the desired tabs. Usage: `\{{jsfiddle [id] [tabs]}}`
* **gist**: Downloads and embeds public GitHub Gists by adding only the id of the Gist. Usage: `\{{gist [id] [file]}}`
Many additional helpers are available in the following categories:
* `assemble`
* `collections`
* `comparisons`
* `dates`
* `file`
* `html`
* `inflections`
* `logging`
* `markdown`
* `math`
* `miscellaneous`
* `numbers`
* `objects`
* `path`
* `special`
* `strings`
* `url`
> Visit the [helper documentation]( to learn more →
## Related info
* [Custom Helpers][custom-helpers]
* [Underscore Mixins]( "Underscore Mixins")
* [Templates][templates-overview]
* [handlebars-helpers Github repo][handlebars-helpers]
* [ Block Helpers]( "Block Helpers")
* [Treehouse Blog, Handlebars.js Part 2: Partials and Helpers](
* [NetTuts+: An Introduction to Handlebars](
[handlebars-helpers]: "Extensive collection of Handlebars helpers"