handlebars-helper-slugify

{{slugify}} handlebars helper. Uses the awesome underscore.string to transform text into a URL slug. Replaces whitespaces, accentuated and special characters with a dash.

npm install handlebars-helper-slugify
24 downloads in the last day
117 downloads in the last week
569 downloads in the last month

{{slugify}} NPM version

Transform text into a URL slug. Replaces whitespaces, accentuated and special characters with a dash.

Installation

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

Register the helper

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

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

Now that the helper is registered, you may begin using it in your templates.

Usage

Given file name: Executive Summary 2013.md:

{{slugify page.filename}}

Renders to executive-summary-2013.md.

Credit

Thank you to the maintainers and contributors of underscore.string, "String manipulation extensions for Underscore.js javascript library". This is a simple helper, but underscore.string has many useful mixins for Underscore/Lo-Dash that I get value from every day. So again, "thank you"!

Author

Jon Schlinkert

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

npm loves you