Permalink
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](https://github.com/assemble/grunt-init-assemble-helper) | [grunt-init-assemble-helper](https://github.com/assemble/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/variables.md`. Usage: `\{{dirname [path]}}`
* **pagename**: Returns the full-name of a given file. Would return: `variables.md`. Usage: `\{{filename "docs/toc.md"}}`
* **filename**: Can be used as an alternate for `pagename`.
* **basename**: Returns the basename of a given file. Would return: `variables` Usage: `\{{base "docs/toc.md"}}`
* **extension**: Returns the extension of a given file. Would return: `.md` Usage: `\{{extension "docs/toc.md"}}`
* **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](http://assemble.io/helpers/) to learn more →
## Related info
* [Custom Helpers][custom-helpers]
* [Underscore Mixins](http://github.com/assemble/underscore-mixins "Underscore Mixins")
* [Templates][templates-overview]
* [handlebars-helpers Github repo][handlebars-helpers]
* [Handlebarsjs.com Block Helpers](http://handlebarsjs.com/block_helpers.html "Block Helpers")
* [Treehouse Blog, Handlebars.js Part 2: Partials and Helpers](http://blog.teamtreehouse.com/handlebars-js-part-2-partials-and-helpers)
* [NetTuts+: An Introduction to Handlebars](http://net.tutsplus.com/tutorials/javascript-ajax/introduction-to-handlebars/)
[handlebars-helpers]: http://github.com/assemble/handlebars-helpers "Extensive collection of Handlebars helpers"