/**
  * @author Andreas Glaser
  */
 public function testAttributes()
 {
     $attributesHelper = new AttributesHelper();
     $attributesHelper->setId('myid')->addClass('myclass')->addData('mydata1', 'cheese')->addData('mydata2', 'bacon')->addStyle('height', '100%')->addStyle('width', '200px')->set('href', 'http://andreas.glaser.me');
     $this->assertEquals(' id="myid" class="myclass" href="http://andreas.glaser.me" data-mydata1="cheese" data-mydata2="bacon" style="height:100%;width:200px;"', $attributesHelper->render());
     $attributesHelper->removeClass('myclass');
     $attributesHelper->removeData('mydata2');
     $attributesHelper->removeId();
     $this->assertEquals(' href="http://andreas.glaser.me" data-mydata1="cheese" style="height:100%;width:200px;"', $attributesHelper->render());
     $this->assertEquals(' id="my-id" class="testclass" data-important="info" data-cheese="delicious" style="color:red;font-size:1em;"', AttributesHelper::f(['id' => 'my-id', 'CLASS' => 'testclass', 'data-important' => 'info', 'data-cheese' => 'delicious', 'style' => 'color:red;font-size:1em'])->render());
 }
Ejemplo n.º 2
0
 /**
  * @param \AndreasGlaser\Helpers\Interfaces\RendererInterface|null $renderer
  *
  * @return string
  * @author Andreas Glaser
  */
 public function render(RendererInterface $renderer = null)
 {
     if ($renderer) {
         return $renderer->render($this);
     }
     return '<td' . $this->attributes->render() . '>' . $this->content . '</td>';
 }
Ejemplo n.º 3
0
 /**
  * @param \AndreasGlaser\Helpers\Interfaces\RendererInterface|null $renderer
  *
  * @return string
  * @author Andreas Glaser
  */
 public function render(RendererInterface $renderer = null)
 {
     if ($renderer) {
         return $renderer->render($this);
     }
     $html = '<tr' . $this->attributes->render() . '>';
     foreach ($this->getCells() as $cell) {
         $html .= $cell->render();
     }
     $html .= '</tr>';
     return $html;
 }