Ghost/ghost/admin/app/helpers/background-image-style.js
Kevin Ansfield 5b43350112 Add {{background-image-style}} helper
no issue
- cleans up multiple CPs that were only outputting a background image style
- moves URL decoding/encoding and `htmlSafe` output into one place
2018-05-14 13:04:53 +01:00

14 lines
342 B
JavaScript

import {helper} from '@ember/component/helper';
import {htmlSafe} from '@ember/string';
export function backgroundImageStyle([url]/*, hash*/) {
if (url) {
let safeUrl = encodeURI(decodeURI(url));
return htmlSafe(`background-image: url(${safeUrl});`);
}
return '';
}
export default helper(backgroundImageStyle);