Skip to content

Instantly share code, notes, and snippets.

@damour
Created April 9, 2013 10:04
Show Gist options
  • Save damour/5344566 to your computer and use it in GitHub Desktop.
Save damour/5344566 to your computer and use it in GitHub Desktop.
<?
//Controller:
if ($this->getRequest()->isXmlHttpRequest())
{
$response = new JsonResponse();
$response->setData(array(
'title' => $title,
'data' => $this->render('AcmeMainBundle:Default:index.html.twig'
)
));
return new JsonResponse(array(
'title' => $title,
'data' => $this->render('AcmeMainBundle:Default:index.html.twig'
)));
//return $response;
}
return $this->render('SothysMainBundle:Default:index.html.twig');
//Twig:
{% extends app.request.xmlHttpRequest
? 'AcmeMainBundle:Default:ajax-layout.html.twig'
: 'AcmeMainBundle:Default:layout.html.twig' %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment