How to intercept templates rendered in PHP for whitelists

Viewed 4

I want to render a template (from Handlebars or Mustache) but then remove all the tags which are not on a whitelist, before adding them to the document.

The easiest way is probably to walk the DOM of the element (before it is inserted ibto the document) and remove all elements whose tag is not on the whitelist. Right?

Or is there a way to do this on the template level? Like, how do I do this if the rendering occurred in PHP? If I let PHP send HTML then it’s too late, the browser will just render and execute the script tags

0 Answers
Related