Skip to content
Advertisement

How to render json into a twig in Symfony2

The question is how to pass a json to twig to render a template. I’ve tried to pass a json with JsonResponse object but I did not find the way to render the template.

TarifasController.php

JavaScript

index.html.twig

JavaScript

How can I pass a json from the controller to use it in the DataTable (in twig template) but mantaining the render in this controller. Please, can you help me?

Advertisement

Answer

I don’t understand what you are trying to achieve but you can simply send json encoded and normal data to your twig, to use it how you want

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement