UNPKG

565 Btext/coffeescriptView Raw
1handlebars = require 'handlebars'
2sysPath = require 'path'
3
4module.exports = class HandlebarsCompiler
5 brunchPlugin: yes
6 type: 'template'
7 extension: 'hbs'
8 pattern: /\.(?:hbs|handlebars)$/
9
10 constructor: (@config) ->
11 null
12
13 compile: (data, path, callback) ->
14 try
15 content = handlebars.precompile data
16 result = "module.exports = Handlebars.template(#{content});"
17 catch err
18 error = err
19 finally
20 callback error, result
21
22 include: [
23 (sysPath.join __dirname, '..', 'vendor',
24 'handlebars.runtime-1.0.rc.3.js')
25 ]