helpers /  Path

Path

Path helpers are node.js utilities for handling and transforming file paths. As with node.js:

"these helpers perform only string transformations. The file system is not consulted to check whether paths are valid."

{{_dirname}}

Return the directory name of a path. Similar to the Unix dirname command.

Template:

{{_dirname '/foo/bar/baz/asdf/quux'}}

Renders to:

'/foo/bar/baz/asdf'

{{_extname}}

"Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string."

Parameters: string (the value to test against). Default: none

Template:

{{_extname 'index.html'}}

Renders to:

.html

Template:

{{_extname 'index.'}}

Renders to:

.

Template:

{{_extname 'index'}}

Returns nothing.

{{_relative}}

Derive the relative path from one absolute path to another (e.g from path A, to path B).
Parameters: string (the value to test against)
Default: none

Example:

{{_relative "from" "to"}}

Template:

<a href="{{_relative "src" "dist"}}/assets/css/styles.css"></a>

Renders to:

<a href="../../dist/assets/css/styles.css"></a>

See the template for this page →

Find an error? Let us know →