Handlebars helper for generating a relative link from the current page to the specified page.
npm install handlebars-helper-relnpm i handlebars-helper-rel.
devDependencies and keywords in your project's package.json:
json
{
"devDependencies": {
"handlebars-helper-rel": "*"
},
"keywords": [
"handlebars-helper-rel"
]
}
`
Alternatively, to register the helper explicitly in the Gruntfile:
`javascript
grunt.initConfig({
assemble: {
options: {
// the 'handlebars-helper-rel' npm module must also be listed in
// devDependencies for assemble to automatically resolve the helper
helpers: ['handlebars-helper-rel', 'foo/*.js']
},
files: {
'dist/': ['src/templates/*.hbs']
}
}
});
`
Usage
With the helper registered, you may now begin using it in your templates:
`html
`
$3
If a site.root variable is defined in the context, then you can omit that part from the paths.
For example, let's say you are using a _config.yml file:
`js
grunt.initConfig({
site: grunt.file.readYAML('_config.yml'),
// Build HTML from templates and data
assemble: {
options: {
// Metadata
site: '<%= site %>',
...
},
example: {
files: {'<%= site.dest %>/': ['<%= site.templates %>/*.hbs']}
}
}
});
`
And it contains a root variable:
`yaml
root: foo/bar
`
Then you can omit foo/bar from the paths defined in your templates:
`html
``