7 var https
= require('https');
8 var path
= require('path');
9 var extname
= path
.extname
;
12 * Expose `GithubView`.
15 module
.exports
= GithubView
;
18 * Custom view that fetches and renders
19 * remove github templates. You could
20 * render templates from a database etc.
23 function GithubView(name
, options
){
25 options
= options
|| {};
26 this.engine
= options
.engines
[extname(name
)];
27 // "root" is the app.set('views') setting, however
28 // in your own implementation you could ignore this
29 this.path
= '/' + options
.root
+ '/master/' + name
;
36 GithubView
.prototype.render = function(options
, fn
){
39 host
: 'raw.githubusercontent.com',
45 https
.request(opts
, function(res
) {
47 res
.setEncoding('utf8');
48 res
.on('data', function(str
){ buf
+= str
});
49 res
.on('end', function(){
50 self
.engine(buf
, options
, fn
);