Skip to content

Commit

Permalink
[FrameworkBundle] added the possibility to render a template for a di…
Browse files Browse the repository at this point in the history
…fferent format than the one from the current Request
  • Loading branch information
fabpot committed Aug 17, 2010
1 parent 51680a2 commit f48aeb1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Symfony/Bundle/FrameworkBundle/Templating/Engine.php
Expand Up @@ -136,7 +136,7 @@ protected function escapeParameters(array $parameters)
return $parameters;
}

// Bundle:controller:action(:renderer)
// Bundle:controller:action(.format)(:renderer)
public function splitTemplateName($name, array $defaults = array())
{
$parts = explode(':', $name, 4);
Expand All @@ -157,13 +157,18 @@ public function splitTemplateName($name, array $defaults = array())
)
);

if (isset($parts[3]) && $parts[3]) {
$options['renderer'] = $parts[3];
if (false !== $pos = strpos($parts[2], '.')) {
$options['format'] = substr($parts[2], $pos);
$parts[2] = substr($parts[2], 0, $pos);
} else {
$format = $this->container->getRequestService()->getRequestFormat();
if (null !== $format && 'html' !== $format) {
$options['format'] = '.'.$format;
}
}

$format = $this->container->getRequestService()->getRequestFormat();
if (null !== $format && 'html' !== $format) {
$options['format'] = '.'.$format;
if (isset($parts[3]) && $parts[3]) {
$options['renderer'] = $parts[3];
}

return array($parts[2], $options);
Expand Down

0 comments on commit f48aeb1

Please sign in to comment.