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 transform()
 {
     // 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()');
     $content = $this->getParentObject()->getPlaceHolder($this->getAttribute('name'));
     if (!TemplateCondition::applies($condition, $content)) {
         return '';
     }
     // inject place holder content into data attribute to make it accessible within the tag for displaying
     if (is_string($content)) {
         // Automatically replace simple place holders.
         // Allow default content output by omitting place holder in case not necessary.
         $this->setPlaceHolder(self::PLACE_HOLDER_NAME, $content);
     } elseif (is_array($content) || is_object($content)) {
         // inject content into a data attribute for further access
         $this->setData(self::PLACE_HOLDER_NAME, $content);
     }
     return $this->transformChildrenAndPreserveContent();
 }
 public function testUnknownCondition()
 {
     $this->assertFalse(TemplateCondition::applies('foo()', null));
 }