/** * {@inheritdoc} */ protected function getContentTemplate() { $branches = isset($this->attributes['when'][0]) ? $this->attributes['when'] : [$this->attributes['when']]; $template = '<xsl:choose>'; foreach ($branches as $when) { $template .= '<xsl:when test="' . htmlspecialchars($when['test'], ENT_COMPAT, 'UTF-8') . '">' . $this->templateBuilder->getTemplate($when) . '</xsl:when>'; } $template .= '<xsl:otherwise>' . $this->templateBuilder->getTemplate($this->attributes['otherwise']) . '</xsl:otherwise></xsl:choose>'; return $template; }
/** * @testdox Supports multiple choice templates */ public function testMulti() { $templateBuilder = new TemplateBuilder(); $template = $templateBuilder->getTemplate(['choose' => ['when' => ['test' => '@foo', 'iframe' => ['width' => '100', 'height' => '100', 'src' => 'foo']], 'otherwise' => ['flash' => ['width' => '200', 'height' => '200', 'src' => 'bar']]]]); $this->assertContains('<iframe', $template); $this->assertContains('<object', $template); }