mirror of
https://github.com/namibia/tips.git
synced 2024-11-05 21:07:53 +00:00
25 lines
487 B
JavaScript
25 lines
487 B
JavaScript
function escapeStr(str) {
|
|
return str
|
|
.replace(/\"/g, '\\"')
|
|
.replace(/\n/g, '\\n');
|
|
}
|
|
|
|
var render = function(data) {
|
|
var data = data.data;
|
|
|
|
var tips = [
|
|
'## ' + data.title,
|
|
'```sh',
|
|
data.tip,
|
|
'```',
|
|
'\n'
|
|
];
|
|
Array.isArray(data.alternatives) && tips.push(['__Alternatives:__']) &&
|
|
data.alternatives.map(function(alternative){
|
|
tips = tips.concat(['```sh',alternative,'```','\n'])
|
|
});
|
|
return tips.join('\n');
|
|
};
|
|
|
|
module.exports = render;
|