Templates helper that returns a link path from the current view to the another view.
Install with npm:
$ npm install --save helper-link-to
This helper should be used with an app created with templates or something that inherits from templates. See related projects for some apps that use templates
Setup the helper by registering it with the app:
// assemble is a descendant of `templates`
var app = assemble();
app.engine('hbs', require('engine-handlebars'));
// engines like handlebars can handle a helper name with dashes
app.helper('link-to', require('helper-link-to'));
Use the helper in a handlebars template:
<a href="{{link-to 'about'}}">About</a>
Creates output like:
<a href="./about.html">About</a>
Setup the helper by registering it with the app:
// verb is a descendant of `templates`
var app = verb();
app.engine('md', require('engine-base'));
// engines like `engine-base` cannot handle a helper name with dashes
app.helper('linkTo', require('helper-link-to'));
Use the helper in a template:
- [Getting Started][{%= linkTo("getting-started", "docs") %}]
Creates output like:
- [Getting Started][docs/getting-started.md]
templates helper that creates a link from the current view to the specified view on the specified collection.
Params
key {String|Object}: Name of the view to lookup to link to. May also pass in a view instance link to.name {String}: (optional) Name of the collection to search for the view. (default="pages")props {Array}: Optional array of properties to check when getting the destination path from a view. May use dot notication (data.permalink). (default=["data.path", "dest", "path"])returns {String}: Relative path to the specified view from the current view.Example
{{! Handlebars example linking from "home.html" to "about.html" in the default "pages" collection }}
<a href="{{link-to 'about'}}">About</a>
<!-- Handlebars example linking from "home.html" to "blog/post-1.html" in the "posts" collection -->
<a href="{{link-to 'post-1' 'posts'}}">Post 1</a>
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
| Commits | Contributor |
|---|---|
| 36 | doowb |
| 8 | jonschlinkert |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Brian Woodward
Copyright © 2017, Brian Woodward. Released under the MIT License.
This file was generated by verb-generate-readme, v0.5.0, on April 12, 2017.