-
-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathruntime-loader.js
More file actions
23 lines (17 loc) · 621 Bytes
/
runtime-loader.js
File metadata and controls
23 lines (17 loc) · 621 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
var ejs = require('ejs');
var path = require('path');
var fs = require('fs');
module.exports = function () {};
module.exports.pitch = function (remainingRequest, precedingRequest, data) {
this.cacheable && this.cacheable();
var callback = this.async();
var params = JSON.parse(this.query.slice(1));
var templatePath = path.join(__dirname, '../../tpls/runtime-template.ejs');
this.addDependency(templatePath);
fs.readFile(templatePath, 'utf-8', function (err, template) {
if (err) return callback(err);
template = ejs.render(template, params);
callback(null, template);
});
};