0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 15:28:40 +00:00

Add HTML_Generator::generateFromTokens().

git-svn-id: http://htmlpurifier.org/svnroot/html_purifier/trunk@36 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-04-16 03:42:25 +00:00
parent 1a3887de1b
commit 0c88b090b0
2 changed files with 20 additions and 0 deletions

View File

@ -3,6 +3,14 @@
class HTML_Generator
{
function generateFromTokens($tokens) {
$html = '';
foreach ($tokens as $token) {
$html .= $this->generateFromToken($token);
}
return $html;
}
function generateFromToken($token) {
if (is_a($token, 'MF_StartTag')) {
$attr = $this->generateAttributes($token->attributes);

View File

@ -63,6 +63,18 @@ class Test_HTML_Generator extends UnitTestCase
}
function test_generateFromTokens() {
$tokens = array(
new MF_StartTag('b'),
new MF_Text('Foobar!'),
new MF_EndTag('b')
);
$expect = '<b>Foobar!</b>';
$this->assertEqual($expect, $this->gen->generateFromTokens($tokens));
}
}
?>