Skip to content

Instantly share code, notes, and snippets.

@brianegan
Created December 26, 2011 21:38
Show Gist options
  • Select an option

  • Save brianegan/1522151 to your computer and use it in GitHub Desktop.

Select an option

Save brianegan/1522151 to your computer and use it in GitHub Desktop.
# Requires
DocpadPlugin = require 'docpad/lib/plugin.coffee'
handlebars = require 'handlebars'
# Define Plugin
class HandlebarsPlugin extends DocpadPlugin
# Plugin name
name: 'handlebars'
# Render some content
render: ({inExtension,outExtension,templateData,file}, next) ->
try
if inExtension in ['handlebars','hbs']
file.content = handlebars.compile(file.content)(templateData)
next()
else
next()
catch err
return next(err)
# Export Plugin
module.exports = HandlebarsPlugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment