Created
August 16, 2012 15:14
-
-
Save snirgel/3370902 to your computer and use it in GitHub Desktop.
Returning rendered template as JSON with Symfony2 and Twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class YourController extends Controller | |
| { | |
| public function your_returnAction(){ | |
| $lReturn = array(); | |
| //use renderview instead of render, because renderview returns the rendered template | |
| $lReturn['html'] = $this->renderView('Bundle:Controller:yourtemplate.html.twig'); | |
| return new Response(json_encode($lReturn), 200, array('Content-Type'=>'application/json')); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.