Skip to content

Instantly share code, notes, and snippets.

@Nayjest
Last active December 15, 2015 13:59
Show Gist options
  • Save Nayjest/5270915 to your computer and use it in GitHub Desktop.
Save Nayjest/5270915 to your computer and use it in GitHub Desktop.
Jade 'extends' or 'include' in browser
if (typeof window !== 'undefined') {
/**
* client based path.js
*
*/
require.register("path.js", function(module, exports, require){
var list = [];
module.exports = {
dirname : function(path) {
path = path || "";
var arr = path.split("/");
arr.pop();
return arr.join("/");
},
basename : function(path) {
path = path || "";
var arr = path.split("/");
return arr.pop();
},
join : function() {
var list = [];
for(var i = 0, len = arguments.length; i < len; i++) {
list.push(arguments[i]);
}
return list.join("/");
}
}
})
/**
* client based fs.js
*
*/
require.register("fs.js", function(module, exports, require){
module.exports = {
readFileSync : function (filename, encoding) {
var xhr = new XMLHttpRequest();
xhr.open('GET', filename, false);
xhr.send(null);
return xhr.responseText;
}
}
})
}
@Nayjest
Copy link
Author

Nayjest commented Mar 29, 2013

Related issue pugjs/pug#714

@Nayjest
Copy link
Author

Nayjest commented Mar 29, 2013

Paste it inside jade.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment