Skip to content
require jade files in node
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

Build Status

jadequire

require jade files in node (synchronously)


Uses require.extensions[] internally, and fs.readFileSync, so be aware of the synchronous i/o happening if you use this (i.e. not in a request handler).

npm install jadequire

register handler

var jadequire = require('jadequire');

jadequire({
  extension: '.jade', // default
  encoding: 'utf8', // default
  compileDebug: false, // default
  // ... any other options you can pass into jade.compile()
});

...and require your jade files

//template.jade
h1 {#name}
h2 I was the turkey the whole time! 
// yes, this is synchronous i/o, so be careful where you use it
var tpl = require('template.jade');

tpl({name:'Zim'});
<h1>Zim</h1>
<h2>I was the turkey the whole time!</h2>

unregister handler

jadequire.remove(); // removes '.jade' extension handler

jadequire.remove('.jd') // specify handler to remove

// jadequire also returns a handler that can be removed
var handler = jadequire({
  extension: '.jd'
});

handler.remove(); // removes the .jd extension handler
Something went wrong with that request. Please try again.