private function searchAndReplace(\DOMNodeList $nodeList, DocumentInterface $document) { $lexer = new Lexer($this->brackets); $mapper = new TagMapper(); /** @var $node \DOMElement */ foreach ($nodeList as $node) { $decodedValue = utf8_decode($node->nodeValue); $lexer->setInput($decodedValue); while ($tag = $mapper->parse($lexer)) { foreach ($tag->getFunctions() as $function) { $expression = $document->getExpression($function['function'], $tag); $expression->execute($function['arguments'], $node); } // insert simple value-of if ($tag->hasFunctions() === false) { $absolutePath = '/' . Processor::VALUE_NODE . '/' . $tag->getXmlPath(); Processor::insertTemplateLogic($tag->getTextContent(), $absolutePath, $node); } } } }