Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.compile = function (content, options, fn) {
// Copy data to root
options = Object.assign({}, options, DEFAULT_OPTIONS, options.data);
jade.render(content, options, (err, content) => {
if (err) {
err.filepath = options.filepath;
return fn(err);
}
fn(null, content);
});
};
function _render(relativePath, data) {
// templateCache = {};
let filePath = path.join(global.RootDir, relativePath);
if (!(filePath in templateCache)) {
templateCache[filePath] = jade.compileFile(filePath, {
pretty: true
});
}
return templateCache[filePath](data);
}
function HTMLCov(runner) {
var jade = require('jade')
, file = __dirname + '/templates/coverage.jade'
, str = fs.readFileSync(file, 'utf8')
, fn = jade.compile(str, { filename: file })
, self = this;
JSONCov.call(this, runner, false);
runner.on('end', function(){
process.stdout.write(fn({
cov: self.cov
, coverageClass: coverageClass
}));
});
}
function HTMLCov(runner) {
var jade = require('jade')
, file = __dirname + '/templates/coverage.jade'
, str = fs.readFileSync(file, 'utf8')
, fn = jade.compile(str, { filename: file })
, self = this;
JSONCov.call(this, runner, false);
runner.on('end', function(){
process.stdout.write(fn({
cov: self.cov
, coverageClass: coverageClass
}));
});
}
function jadeify (filename, options) {
options || (options = {});
options.package = package;
options.linktype = linktype;
options.href = href;
options.klass = klass;
jade.renderFile(filename, options, function (err, str) {
if (err) return console.error(err.stack);
var newfile = filename.replace('.jade', '.html')
fs.writeFile(newfile, str, function (err) {
if (err) return console.error('could not write', err.stack);
console.log('%s : rendered ', new Date, newfile);
});
});
}
function HTMLCov(runner) {
var jade = require('jade')
, file = __dirname + '/templates/coverage.jade'
, str = fs.readFileSync(file, 'utf8')
, fn = jade.compile(str, { filename: file })
, self = this;
JSONCov.call(this, runner, false);
runner.on('end', function(){
process.stdout.write(fn({
cov: self.cov
, coverageClass: coverageClass
}));
});
}
function HTMLCov(runner) {
var jade = require('jade')
, file = __dirname + '/templates/coverage.jade'
, str = fs.readFileSync(file, 'utf8')
, fn = jade.compile(str, { filename: file })
, self = this;
JSONCov.call(this, runner, false);
runner.on('end', function(){
process.stdout.write(fn({
cov: self.cov
, coverageClass: coverageClass
}));
});
}
function HTMLCov(runner) {
var jade = require('jade')
, file = __dirname + '/templates/coverage.jade'
, str = fs.readFileSync(file, 'utf8')
, fn = jade.compile(str, { filename: file })
, self = this;
JSONCov.call(this, runner, false);
runner.on('end', function(){
process.stdout.write(fn({
cov: self.cov
, coverageClass: coverageClass
}));
});
}
function renderJade(filepath, locals) {
var env = process.env.NODE_ENV;
if (env === 'production') {
if (!viewCache[filepath]) {
viewCache[filepath] = jade.compileFile(filepath);
}
return viewCache[filepath](locals);
}
return jade.renderFile(filepath, locals);
}
function renderJade(filepath,locals){
var env = process.env.NODE_ENV;
if( env ==='production' ){
if(!viewCache[filepath]){
viewCache[filepath] = jade.compileFile(filepath);
}
return viewCache[filepath](locals);
}else{
return jade.renderFile(filepath,locals);
}
}