UNPKG

620 BJavaScriptView Raw
1'use strict';
2
3var ejs = require('ejs');
4var path = require('path');
5var fs = require('fs');
6
7module.exports = function () {};
8module.exports.pitch = function (remainingRequest, precedingRequest, data) {
9 this.cacheable && this.cacheable();
10
11 var callback = this.async();
12 var params = JSON.parse(this.query.slice(1));
13 var templatePath = path.join(__dirname, '../../tpls/runtime-template.js');
14
15 this.addDependency(templatePath);
16
17 fs.readFile(templatePath, 'utf-8', function (err, template) {
18 if (err) return callback(err);
19
20 template = ejs.render(template, params);
21 callback(null, template);
22 });
23};
\No newline at end of file