Skip to content

Instantly share code, notes, and snippets.

@snirgel
snirgel / gist:3370902
Created August 16, 2012 15:14
Returning rendered template as JSON with Symfony2 and Twig
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'));
}
}
@snirgel
snirgel / jquery.mirrorvalue.js
Created March 14, 2012 11:03
Mirrors the input of an textfield, identified by id
/**
* @author Karina Mies
* @description Mirrors the input of an textfield, identified by id
*/
jQuery.fn.mirrorValue = function(){
return this.each(function(){
var lCurrentText, lId, lMirrorClass;
jQuery(this).keyup(function(e) {
lId = '#'+jQuery(this).attr('id');
lMirrorClass = '.'+jQuery(this).attr('id')+'-mirror';