/** * Initialize the tag. * @param string $name The name of the tag (i.e., the XML element name). * @param array $attributes The tag/element attributes. */ public function __construct($name, array $attributes = array(), Pagemill_Tag $parent = null, Pagemill_Doctype $doctype = null) { //$this->attach(self::EVENT_BEFORE, new Pagemill_Tag_Event_AttributeHandler()); $this->_originalName = $name; $this->_originalAttributes = $attributes; $this->name = $name; $this->attributes = $attributes; if ($parent) { $parent->appendChild($this); } if (is_null($doctype)) { if (!is_null($parent)) { $this->_doctype = $parent->doctype(); } } else { $this->_doctype = $doctype; } }
public function process(Pagemill_Tag $tag, Pagemill_Data $data, Pagemill_Stream $stream) { $attributes = array(); $name = $this->_loopAttributes; $parts = explode(' ', $name, 2); $attributes['name'] = $parts[0]; if (isset($parts[1])) { $attributes['as'] = $parts[1]; } $loop = new Pagemill_Tag_Loop('loop', $attributes, null, $tag->doctype()); $temptag = new Pagemill_Tag($tag->name(), $tag->attributes(), null, $tag->doctype()); foreach ($tag->children() as $child) { $temptag->appendChild($child); } $loop->appendChild($temptag); $loop->process($data, $stream); foreach ($temptag->children() as $child) { $tag->appendChild($child); } return false; }