Skip to content

{{isactive}} handlebars helper. Adds an 'active' class to the 'current page'. Class can be customized.

License

Notifications You must be signed in to change notification settings

helpers/handlebars-helper-isActive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

{{isActive}} NPM version

Generate relative links from the "current page" to other dest pages.

Installation

Use npm to install the package: npm i handlebars-helper-isactive.

Register the helper

In your project's Gruntfile, to register the helper add handlebars-helper-isactive to the helpers property in the Assemble task or target options:

grunt.initConfig({
  assemble: {
    options: {
      // the 'handlebars-helper-isactive' npm module must also be listed in
      // devDependencies for assemble to automatically resolve the helper
      helpers: ['handlebars-helper-isactive', 'foo/*.js']
    },
    files: {
      'dist/': ['src/templates/*.hbs']
    }
  }
});

Alternatively, you can avoid defining the helper in the Assemble task options by adding module to both the devDependencies and keywords in your project's package.json.

{
  "name": "foo",
  "version": "0.1.0",
  "devDependencies": {
    "handlebars-helper-isactive": "*"
  },
  "keywords": [
    "handlebars-helper-isactive"
  ]
}

Usage

With the helper registered, you may now begin using it in your templates.

Examples also shows the {{autolink}} helper.

In a "page"

{{#each pages}}
  <a href="{{autolink}}" {{isActive}}>{{data.title}}</a>
{{/each}}

In a "layout"

{{#each pages}}
  <a href="{{autolink}}" {{isActive}}>{{../title}}</a>
{{/each}}

Renders to:

<a href="foo.html" class="active">Foo</a>
<a href="bar.html">Bar</a>
<a href="baz.html">Baz</a>

Author

Jon Schlinkert

License and Copyright

Licensed under the MIT License Copyright (c) Jon Schlinkert, contributors.

About

{{isactive}} handlebars helper. Adds an 'active' class to the 'current page'. Class can be customized.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  
  •  

Packages