Skip to content

Commit f48aeb1

Browse files
committed
[FrameworkBundle] added the possibility to render a template for a different format than the one from the current Request
1 parent 51680a2 commit f48aeb1

File tree

1 file changed

+11
-6
lines changed
  • src/Symfony/Bundle/FrameworkBundle/Templating

1 file changed

+11
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/Engine.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected function escapeParameters(array $parameters)
136136
return $parameters;
137137
}
138138

139-
// Bundle:controller:action(:renderer)
139+
// Bundle:controller:action(.format)(:renderer)
140140
public function splitTemplateName($name, array $defaults = array())
141141
{
142142
$parts = explode(':', $name, 4);
@@ -157,13 +157,18 @@ public function splitTemplateName($name, array $defaults = array())
157157
)
158158
);
159159

160-
if (isset($parts[3]) && $parts[3]) {
161-
$options['renderer'] = $parts[3];
160+
if (false !== $pos = strpos($parts[2], '.')) {
161+
$options['format'] = substr($parts[2], $pos);
162+
$parts[2] = substr($parts[2], 0, $pos);
163+
} else {
164+
$format = $this->container->getRequestService()->getRequestFormat();
165+
if (null !== $format && 'html' !== $format) {
166+
$options['format'] = '.'.$format;
167+
}
162168
}
163169

164-
$format = $this->container->getRequestService()->getRequestFormat();
165-
if (null !== $format && 'html' !== $format) {
166-
$options['format'] = '.'.$format;
170+
if (isset($parts[3]) && $parts[3]) {
171+
$options['renderer'] = $parts[3];
167172
}
168173

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

0 commit comments

Comments
 (0)