0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/server/lib/mobiledoc/cards/code.js

25 lines
532 B
JavaScript
Raw Normal View History

module.exports = {
name: 'code',
type: 'dom',
render(opts) {
let payload = opts.payload;
let dom = opts.env.dom;
if (!payload.code) {
return '';
}
let pre = dom.createElement('pre');
let code = dom.createElement('code');
if (payload.language) {
code.setAttribute('class', `language-${payload.language}`);
}
code.appendChild(dom.createTextNode(payload.code));
pre.appendChild(code);
return pre;
}
};