mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
fa4e68ba13
no issue - adds abolsute->relative and relative->absolute transformer methods to card definitions - allows for each card to tailor it's transformation to the specific needs of it's payload so that the `mobiledoc` field can be transformed successfully during API serialization/deserialization
25 lines
784 B
JavaScript
25 lines
784 B
JavaScript
const createCard = require('../create-card');
|
|
|
|
module.exports = createCard({
|
|
name: 'html',
|
|
type: 'dom',
|
|
render(opts) {
|
|
if (!opts.payload.html) {
|
|
return '';
|
|
}
|
|
|
|
// use the SimpleDOM document to create a raw HTML section.
|
|
// avoids parsing/rendering of potentially broken or unsupported HTML
|
|
return opts.env.dom.createRawHTMLSection(opts.payload.html);
|
|
},
|
|
|
|
absoluteToRelative(urlUtils, payload, options) {
|
|
payload.html = payload.html && urlUtils.htmlAbsoluteToRelative(payload.html, options);
|
|
return payload;
|
|
},
|
|
|
|
relativeToAbsolute(urlUtils, payload, options) {
|
|
payload.html = payload.html && urlUtils.htmlRelativeToAbsolute(payload.html, options);
|
|
return payload;
|
|
}
|
|
});
|