Docs /  templates


Built-in Helpers

Assemble includes the handlebars-helpers library as a dependency, so more than 100 Handlebars helpers ofrom that library are available by default.

Also see 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 forextension.
  • 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 →

See the template for this page →

Find an error? Let us know →