Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/docpad/docpad-plugin-handlebars
Adds support for the Handlebars templating engine to DocPad.
https://github.com/docpad/docpad-plugin-handlebars
docpad-plugin
Last synced: 3 months ago
JSON representation
Adds support for the Handlebars templating engine to DocPad.
- Host: GitHub
- URL: https://github.com/docpad/docpad-plugin-handlebars
- Owner: docpad
- License: other
- Created: 2012-10-17T02:00:35.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-02-19T20:25:56.000Z (11 months ago)
- Last Synced: 2024-09-28T14:04:10.102Z (3 months ago)
- Topics: docpad-plugin
- Language: CoffeeScript
- Homepage:
- Size: 242 KB
- Stars: 7
- Watchers: 15
- Forks: 12
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Handlebars Plugin for [DocPad](https://docpad.org)
Adds support for the [Handlebars](http://handlebarsjs.com/) templating engine to [DocPad](https://docpad.org)
Convention: `.(inlinejs|js|anything).(handlebars|hbs|hb)`
## 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](http://docpad.org/docs/config) manually:
``` coffee
# ...
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: '{{document.title}}
'
goUp: 'Scroll up'
# ...
```In your handlebars template you will need to use {{{content}}} to prevent handlebars from escaping any html content. You also cannot use helper functions as a parameter to {{#each collection}}, instead you should define a templateData variable and map the name to a @getCollection call e:g:
```
sitePages: ->
@getCollection("pages").toJSON()
```## 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:
``` coffee
# ...
plugins:
handlebars:
precompileOpts:
wrapper: "default"
# ...
```Available values for the wrapper option are:
- `"default"`: Produces a handlebars wrapper like:
``` javascript
(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:
``` javascript
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:
``` javascript
function (Handlebars,depth0,helpers,partials,data) {
...
}
```Install
Install this DocPad plugin by entering
docpad install handlebars
into your terminal.History
Discover the release 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?
Contributors
These amazing people have contributed code to this project:
-
Benjamin Lupton — view contributions -
Gilles Bouthenot — view contributions -
Mike Moulton — view contributions -
Rob Loach — view contributions -
Tim Mackinnon — view contributions -
Tobias Birmili — view contributions -
vsopvsop — view contributions
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
License
Unless stated otherwise all works are:
- Copyright © 2012+ Mike Moulton
and licensed under: