1 |
|
2 | (function() {
|
3 | var HandlebarsCompiler, handlebars, sysPath;
|
4 |
|
5 | handlebars = require('handlebars');
|
6 |
|
7 | sysPath = require('path');
|
8 |
|
9 | module.exports = HandlebarsCompiler = (function() {
|
10 |
|
11 | HandlebarsCompiler.prototype.brunchPlugin = true;
|
12 |
|
13 | HandlebarsCompiler.prototype.type = 'template';
|
14 |
|
15 | HandlebarsCompiler.prototype.extension = 'hbs';
|
16 |
|
17 | HandlebarsCompiler.prototype.pattern = /\.(?:hbs|handlebars)$/;
|
18 |
|
19 | function HandlebarsCompiler(config) {
|
20 | this.config = config;
|
21 | null;
|
22 | }
|
23 |
|
24 | HandlebarsCompiler.prototype.compile = function(data, path, callback) {
|
25 | var content, error, result;
|
26 | try {
|
27 | content = handlebars.precompile(data);
|
28 | return result = "module.exports = Handlebars.template(" + content + ");";
|
29 | } catch (err) {
|
30 | return error = err;
|
31 | } finally {
|
32 | callback(error, result);
|
33 | }
|
34 | };
|
35 |
|
36 | HandlebarsCompiler.prototype.include = [sysPath.join(__dirname, '..', 'vendor', 'handlebars.runtime-1.0.rc.3.js')];
|
37 |
|
38 | return HandlebarsCompiler;
|
39 |
|
40 | })();
|
41 |
|
42 | }).call(this);
|