Ghost/ghost/admin/helpers/gh-format-html.js
2014-07-31 17:42:43 +01:00

18 lines
752 B
JavaScript

/* global Handlebars, html_sanitize*/
import cajaSanitizers from 'ghost/utils/caja-sanitizers';
var formatHTML = Ember.Handlebars.makeBoundHelper(function (html) {
var escapedhtml = html || '';
// replace script and iFrame
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
'<pre class="js-embed-placeholder">Embedded JavaScript</pre>');
escapedhtml = escapedhtml.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
'<pre class="iframe-embed-placeholder">Embedded iFrame</pre>');
// sanitize HTML
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
return new Handlebars.SafeString(escapedhtml);
});
export default formatHTML;