mirror of
https://github.com/namibia/tips.git
synced 2024-12-23 10:38:58 +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;
|