Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docpad-plugin-handlebars

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docpad-plugin-handlebars

Adds support for the Handlebars templating engine to DocPad.

  • 2.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
Maintainers
2
Weekly downloads
 
Created
Source

Handlebars Plugin for DocPad

Build Status NPM version Flattr donate button PayPayl donate button

Adds support for the Handlebars templating engine to DocPad

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

Install

npm install --save docpad-plugin-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

You can discover the history inside the History.md file

Contributing

You can discover the contributing instructions inside the Contributing.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2012+ Mike Moulton mike@meltmedia.com

Keywords

FAQs

Package last updated on 25 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc