You have several options:
Handlebars.registerHelper('strip-scripts', function(context) { var html = context;
Then use it in your template as follows:
{{strip-scripts foo}}
You do not need to use triple braces when using the helper, because your helper already returns a SafeString.
A helper may be more useful than the first option, because you can reuse it in all of your templates.
Check out this question in StackOverflow for help on how to safely erase script tags: Removing all script tags from html using JS regex
If you are doing this server side using Node.js, you can use something like Cheerio instead of jQuery.
source share