public function enterTag(Tag $node) { $name = $node->getTagName(); $flags = $node->getFlags(); if ($flags & Tag::FLAG_REMOVE_INNER_WHITESPACES) { $name .= '<'; } if ($flags & Tag::FLAG_REMOVE_OUTER_WHITESPACES) { $name .= '>'; } if ($flags & Tag::FLAG_SELF_CLOSE) { $name .= '/'; } $this->write('tag(' . $name, true, false)->indent(); if ($node->hasContent()) { $this->raw(' '); $node->getContent()->accept($this); } if ($node->hasAttributes() || $node->hasChilds()) { $this->raw("\n"); } }
public function leaveTag(Tag $node) { if ($node->getFlags() & Tag::FLAG_SELF_CLOSE) { return; } $indent = $this->shouldIndentBeforeClose($node); $break = $this->shouldBreakAfterClose($node); if ($this->shouldBreakAfterOpen($node)) { $this->undent(); } $this->write(sprintf('</%s>', $node->getTagName()), $indent, $break); }