Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let renderTemplate = (data) => {
let compiledTemplate = swig.renderFile(path.join(__dirname, 'index-template.jst'), data)
compiledTemplate = compiledTemplate.replace(/"require\((.[^\)]*)\)"/g, ' require($1)')
return compiledTemplate
}
Router.match({ routes: routes.default, location: req.url }, function(err, redirectLocation, renderProps) {
if (err) {
res.status(500).send(err.message)
} else if (redirectLocation) {
res.status(302).redirect(redirectLocation.pathname + redirectLocation.search)
} else if (renderProps) {
var html = ReactDOM.renderToString(React.createElement(Router.RoutingContext, renderProps));
var page = swig.renderFile('views/index.html', { html: html });
res.status(200).send(page);
} else {
res.status(404).send('Page Not Found')
}
});
});
Router.match({ routes: routes.default, location: req.url }, function(err, redirectLocation, renderProps) {
if (err) {
res.status(500).send(err.message)
} else if (redirectLocation) {
res.status(302).redirect(redirectLocation.pathname + redirectLocation.search)
} else if (renderProps) {
var html = ReactDOM.renderToString(React.createElement(Router.RouterContext, renderProps));
var page = swig.renderFile('views/index.html', { html: html });
res.status(200).send(page);
} else {
res.status(404).send('Page Not Found')
}
});
});
exports.init = function(output){
output = _path.absolute(
output+'/',process.cwd()+'/'
);
var content = require('swig').renderFile(
__dirname+'/template/release.conf',{
comment:'#',
DIR_WEBROOT:'../webapp/'
}
);
_fs.write(output+'release.conf',content);
_logger.info('output release.conf to %s',output);
};
/**
app.get('/', (req, res) => {
const page = swig.renderFile('index.html');
res.status(200).send(page);
});