I'd like to clean the output of my templates using HTMLTidy.
I tried several approaches but I just can't get it right. With the help of this recipe: http://doc.silverstripe.org/doku.php?id=recipes:syntax-highlighting I managed to clean single pieces of the output, but not the whole document.
My idea would be to take the output from SSViewer::process(), run it through tidy->parseString and return it.
I think I need to overwrite the call for ViewableData::renderWith() (not overwrite the function itself) with my own and insert my extension class to SSViewer there.
Roughly like this:
class SSViewerTidy extends SSViewer {
public function process($item) {
$tidy = new tidy;
$tidy->parseString(parent::process($item));
return tidy_get_output($tidy);
}
}
somewhere else:
renderWith(new SSViewerTidy($template))
But I can't find where renderWith() is called when a request is made.
Where is my "somewhere else"?
Any help would be appreciated.