Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting defaults for number_format in Symfony 2

Tags:

twig

symfony

The twig documentation describes how to set the default parameters for the number_format extension. How can I set this in Symfony 2?

like image 942
chiborg Avatar asked Apr 13 '12 22:04

chiborg


1 Answers

Symfony2 does not give access to core extension of twig. You can create a kernel.request event listener, inject twig service and in onKernelRequest method of the listener you have to add

$this->twig->getExtension('core')->setNumberFormat(3, ',', '.'); 
like image 82
Mun Mun Das Avatar answered Oct 13 '22 03:10

Mun Mun Das