public function transform() { $name = $this->getRequiredAttribute('name'); /* @var $iterator HtmlIteratorTag */ $iterator = $this->getParentObject()->getChildNode('name', $name, Iterator::class); $expression = $this->getRequiredAttribute('data'); $data = ExpressionEvaluator::evaluate($this->getParentObject(), $expression); $iterator->fillDataContainer($data); // reset iteration number as we are using one single iterator instance within a loop $iterator->setIterationNumber(1); return ''; }
public function transform() { // Re-map desired model to content data attribute to ease expression and template definition. // Most likely, the model will be a parent document's data attribute. $model = ExpressionEvaluator::evaluate($this->getParentObject(), $this->getRequiredAttribute('content-mapping')); $this->setData('content', $model); // Calculate result to match against condition $result = ExpressionEvaluator::evaluate($this, $this->getRequiredAttribute('expression')); // The condition defines whether or not the content is displayed. Can be overwritten // by the "condition" attribute according to the TemplateCondition capabilities. $condition = $this->getAttribute('condition', 'notEmpty()'); if (!TemplateCondition::applies($condition, $result)) { return ''; } // Mark template for creating output directly as condition matches. $this->transformOnPlace(); return parent::transform(); }
public function testIllegalCall() { $this->setExpectedException(ParserException::class); ExpressionEvaluator::evaluate(new Document(), 'foo-> getCssClass()'); }
public function transform() { return ExpressionEvaluator::evaluate($this->getParentObject(), $this->getAttribute(self::EXPRESSION)); }