diff options
Diffstat (limited to 'packages/markdown/src/template-integration.js')
-rwxr-xr-x | packages/markdown/src/template-integration.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/markdown/src/template-integration.js b/packages/markdown/src/template-integration.js new file mode 100755 index 00000000..bd8eec47 --- /dev/null +++ b/packages/markdown/src/template-integration.js @@ -0,0 +1,18 @@ +import sanitizeXss from 'xss'; + +if (Package.ui) { + const Template = Package.templating.Template; + const UI = Package.ui.UI; + const HTML = Package.htmljs.HTML; + const Blaze = Package.blaze.Blaze; // implied by `ui` + + UI.registerHelper('markdown', new Template('markdown', function () { + const self = this; + let text = ''; + if (self.templateContentBlock) { + text = Blaze._toText(self.templateContentBlock, HTML.TEXTMODE.STRING); + } + + return HTML.Raw(sanitizeXss(Markdown(text))); + })); +} |