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:
parent
1a3887de1b
commit
0c88b090b0
@ -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);
|
||||
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user