Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Adds support for the Handlebars templating engine to DocPad.
CoffeeScript Handlebars HTML
branch: master
Failed to load latest commit information.
src linting
test fixed tests part 2
.editorconfig Add .editorconfig (v1.3.18 from bevry/base)
.gitignore updated base files
.npmignore updated base files
.travis.yml updated base files
CONTRIBUTING.md updated base files
Cakefile updated base files
HISTORY.md Update dependencies
LICENSE.md updated base files
README.md updated base files
coffeelint.json
package.json updated base files

README.md

Handlebars Plugin for DocPad

Build Status NPM version NPM downloads Dependency Status Dev Dependency Status
Gratipay donate button Flattr donate button PayPayl donate button BitCoin donate button Wishlist browse button

Adds support for the Handlebars templating engine to DocPad

Convention: .(inlinejs|js|anything).(handlebars|hbs|hb)

Install

docpad install handlebars

Configuration

Getting helpers and partials to work

For the plugin to support helpers and partials, you'll have to add something like the following to your docpad configuration file manually:

# ...
plugins:
    handlebars:
        helpers:
            # Expose docpads 'getBlock' function to handlebars
            getBlock: (type, additional...) ->
                additional.pop() # remove the hash object
                @getBlock(type).add(additional).toHTML()
        partials:
            title: '<h1>{{document.title}}</h1>'
            goUp: '<a href="#">Scroll up</a>'
# ...

Usage as precompiler

If the document extension is .(inlinejs|js).(handlebars|hbs|hb), the plugin will produce a precompiled template. In this case, you can customise the precompiled template via the following:

# ...
plugins:
    handlebars:
        precompileOpts:
            wrapper: "default"
# ...

Available values for the wrapper option are:

  • "default": Produces a handlebars wrapper like:

    (function() {
        var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
        templates['theSlugOfTheFile'] = template(function (Handlebars,depth0,helpers,partials,data) {
            ...
        })
    })();
  • "amd": Produces a AMD handlebars wrapper like:

    define(['handlebars'], function(Handlebars) {
        var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
        templates['theSlugOfTheFile'] = template(function (Handlebars,depth0,helpers,partials,data) {
            ...
        });
    });
  • "none": Produces a basic wrapper like:

    function (Handlebars,depth0,helpers,partials,data) {
        ...
    }

History

Discover the change history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gratipay donate button Flattr donate button PayPayl donate button BitCoin donate button Wishlist browse button

Contributors

These amazing people have contributed code to this project:

Become a contributor!

License

Unless stated otherwise all works are:

and licensed under:

Something went wrong with that request. Please try again.