Пример #1
0
 /**
  * Parse emmet style attributes
  *
  * @param Tag $tag
  */
 public function processBlockTags(Tag $tag)
 {
     if ($tag->isInline()) {
         return;
     }
     $text = null;
     $tag->getText()->replace('/(^{([^:\\(\\)]+)}[ \\t]*\\n?|(?:[ \\t]*|\\n?){([^:\\(\\)]+)}\\n*$)/', function (Text $w) use(&$text) {
         $text = $w->trim()->trim('{}');
         return '';
     });
     if ($text) {
         $tag->setAttributes($this->parseAttributes($text));
     }
 }
Пример #2
0
 /**
  * @param Collection $headerCells
  * @param Collection $bodyRows
  *
  * @return Text
  */
 protected function createView(Collection $headerCells, Collection $bodyRows)
 {
     $tHeadRow = new Tag('tr');
     $tHeadRow->setText("\n" . $headerCells->join("\n") . "\n");
     $tHead = new Tag('thead');
     $tHead->setText("\n" . $tHeadRow . "\n");
     $tBody = new Tag('tbody');
     $bodyRows->apply(function (Collection $row) use(&$options) {
         $tr = new Tag('tr');
         $tr->setText("\n" . $row->join("\n") . "\n");
         return $tr;
     });
     $tBody->setText("\n" . $bodyRows->join("\n") . "\n");
     $table = new Tag('table');
     $table->setAttributes(array('class' => 'table'));
     $table->setText("\n" . $tHead . "\n" . $tBody . "\n");
     return new Text($table->render());
 }
 /**
  * {@inheritdoc}
  */
 public function renderTag($tagName, $content, $tagType = Tag::TYPE_BLOCK, array $options = array())
 {
     $options = $this->createResolver()->resolve($options);
     $tag = new Tag($tagName);
     $tag->setType($tagType);
     $tag->setText($content);
     $tag->setAttributes($options['attr']);
     return $tag->render();
 }