public function Icon($name, $attr = null)
 {
     $attr = HtmlGenerator::MergeAttributes($attr, array('class' => 'fa fa-' . $name));
     if (array_key_exists('fw', $attr) && $attr['fw']) {
         $attr = HtmlGenerator::MergeAttributes($attr, array('class' => 'fa-fw'));
         unset($attr['fw']);
     }
     return new Tag('i', null, $attr);
 }
Example #2
0
 /** Tests for {@link HtmlGenerator::createHtml}. */
 public function testCreateHtml()
 {
     $generator = new HtmlGenerator();
     $e = new Element('html');
     $this->assertSame('<html></html>', $generator->createHtml($e), 'HTML for single element incorrect.');
     $e = new Element('html', ['lang' => 'nl']);
     $this->assertSame('<html lang="nl"></html>', $generator->createHtml($e), 'HTML attribute rendered incorrect.');
     $e = new Element('html', []);
     $this->assertSame('<html></html>', $generator->createHtml($e), 'Empty HTML attribute collection rendered incorrect.');
     $e = new Element('html', [], new Element('head'));
     $this->assertSame('<html><head></head></html>', $generator->createHtml($e), 'HTML children rendered incorrect.');
     $e = new Element('p', ['title' => '&']);
     $this->assertSame('<p title="&amp;"></p>', $generator->createHtml($e), '& in attribute not properly escaped.');
     $e = new Element('p', ['title' => '<']);
     $this->assertSame('<p title="&lt;"></p>', $generator->createHtml($e), '< in attribute not properly escaped.');
     $e = new Element('p', ['title' => '>']);
     $this->assertSame('<p title="&gt;"></p>', $generator->createHtml($e), '> in attribute not properly escaped.');
     $e = new Element('p', ['title' => '"']);
     $this->assertSame('<p title="&quot;"></p>', $generator->createHtml($e), '" in attribute not properly escaped.');
     $e = new Element('p', [], '&');
     $this->assertSame('<p>&amp;</p>', $generator->createHtml($e), '& in content not properly escaped.');
     $e = new Element('p', [], '<');
     $this->assertSame('<p>&lt;</p>', $generator->createHtml($e), '< in content  not properly escaped.');
     $e = new Element('p', [], '>');
     $this->assertSame('<p>&gt;</p>', $generator->createHtml($e), '> in content  not properly escaped.');
     $e = new Element('p', [], '"');
     $this->assertSame('<p>"</p>', $generator->createHtml($e), '" in content escaped.');
 }
Example #3
0
 /** Returns a HTML representation of this element and the elements it contains.
  * @return  string                                     the HTML. */
 public function toHtml()
 {
     $generator = new HtmlGenerator();
     return $generator->createHtml($this);
 }
Example #4
0
 public function RenderOpen()
 {
     return '<' . $this->Name . HtmlGenerator::EmitAttributes($this->Attr) . '>';
 }