title: Displaying JSON Data in my Twig template in symfony2
body: <p>I am trying to use a jquery extension as <a href="http://arshaw.com/fullcalendar/" rel="nofollow">Event calendar</a> in my application. I tried it first with core php and it works fine. Now I want to use it in my symfony2 application, but i am not able to display it in my twig file. Here is my code i am using to render but i am not sure where i am doing it incorrect.</p>
  
  <h2>Controller</h2>
  
  <pre><code>public function studentCalendarAction()
  {
    $year = date('Y');
    $month = date('m');
    $response = new Response(json_encode(array(
          array(
                  'id' =&gt; 111,
                  'title' =&gt; "Event1",
                  'start' =&gt; "$year-$month-10",
                  'url' =&gt; "http://yahoo.com/"
          ),
    )));
    $response-&gt;headers-&gt;set('Content-Type', 'application/json');
    return $this-&gt;render('CollegeStudentBundle:StudentAttendance:calendar.html.twig',array('response'=&gt;$response));
  }
  </code></pre>
  
  <h2>Router</h2>
  
  <pre><code>CollegeStudentBundle_attendance_calendar:
      pattern:  /student/attendance/calendar
      defaults: { _controller: CollegeStudentBundle:StudentAttendance:studentCalendar }
      requirements:
          _method:  GET|POST
  </code></pre>
  
  <h2>TWIG</h2>
  
  <pre><code>    &lt;script type='text/javascript'&gt;
  
                  $(document).ready(function() {
  
                  $('#calendar').fullCalendar({
  
                      editable: true,
  
                      events: "../../student/attendance/calendar",
  
                      eventDrop: function(event, delta) {
                          alert(event.title + ' was moved ' + delta + ' days\n' +
                              '(should probably update your database)');
                      },
  
                      loading: function(bool) {
                          if (bool) $('#loading').show();
                          else $('#loading').hide();
                      }
  
                  });
  
              });
  
      &lt;/script&gt;
  
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id='calendar'&gt;&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Even I tried to make my <code>Router</code> like this</p>
  
  <pre><code>CollegeStudentBundle_attendance_calendar:
      pattern:  /student/attendance/calendar
      defaults: { _controller: CollegeStudentBundle:StudentAttendance:studentCalendar, _format: json }
      requirements: { _format: (xml|json), _method: GET }  
  </code></pre>
  
  <p>But this displays the code of twig file.</p>