Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A cordova-client hook to compile ./www/jade/index.jade to ./www/index.html as part of the build process.
#!/usr/bin/env node
/**
* Darryl Pogue, 2012
*
* A cordova-client hook to compile ./www/jade/index.jade to ./www/index.html as part of the build process.
* Requires node.js and jade to be installed.
*
* Copy this into the .cordova/hooks/before_build folder of your project, and make it executable.
*/
var fs = require('fs');
var path = require('path');
function compile_jade(src, dst) {
var jade = require('jade');
var options = {
filename: src,
pretty: true
};
try {
var stat = fs.lstatSync(src);
if (stat.isFile()) {
var str = fs.readFileSync(src, 'utf8');
var fn = jade.compile(str, options);
fs.writeFileSync(dst, fn(options));
}
} catch (e) {
throw e;
}
}
var assets = path.join('.', 'www');
// If ./www/jade/ exists, compile the jade files
var jade_index = path.join(assets, 'jade', 'index.jade');
if (fs.existsSync(jade_index)) {
compile_jade(jade_index, path.join(assets, 'index.html'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.