Created
September 8, 2014 08:53
-
-
Save basicallydan/486f3cfe8e8a1ad7f7b3 to your computer and use it in GitHub Desktop.
Handlebars for Mocha with Browserify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is useful if you are using Mocha for your tests, Browserify for Modules and Handlebars for templates. | |
* It should be set up before running tests | |
* Note that require.extensions is depreciated: http://nodejs.org/api/globals.html#globals_require_extensions | |
* It is based on https://gist.github.com/akre54/11183020 | |
*/ | |
var Handlebars = require('handlebars'); | |
var fs = require('fs'); | |
require.extensions['.hbs'] = function (module, filename) { | |
var compiled; | |
var raw = fs.readFileSync(filename, 'utf8'); | |
compiled = Handlebars.compile(raw); | |
module.exports = compiled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment