Posted on 14/12/08 by Tim Koschützki
one of the problems we faced back when we merged our old blogs thinkingphp.org and php-coding-practices.com, was this little "Recent Comments" feature in the right navbar. It shows syntax-highlighted code, but makes use of Cake's TextHelper's truncate() method at the same time. The problem is obvious: Html can get cut off, totally screwing the page layout.
One day I sat down to solve this problem. The result of this is the following ViewHelper "HtmlCleaner", which could be an easy-to-use alternative for HtmlTidy.
You can find the code including tests on Debuggable Scraps / CakePHP / Helpers. Suggestions and feedback are always welcome.
Usage is very simple:
$bogusHtml = $htmlCleaner->clean($bogusHtml);
-- Tim Koschuetzki aka DarkAngelBGE
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.