I'm have a pretty silly issue. I'm trying to generate an url in twig using JS variables.
It works when I write them manually:
var url = "{{ path('geolocation', {'latitude':'41.39109','longitude':'2.15485','accuracy':'1114'}) }}";
but it doesn't when I use variables instead:
var url = "{{ path('geolocation', {'latitude':latitude,'longitude':longitude,'accuracy':accuracy}) }}";
What could be happening? Of course the variables exist and are correctly defined.
It seems it doesn't get the parameter correctly:
An exception has been thrown during the rendering of a template ("Parameter "accuracy" for route "geolocation" must match "[^/]++" ("" given) to generate a corresponding URL.").
But when I go:
console.log(latitude + " " + longitude + " " + accuracy);
the result is
41.39109 2.15485 1114
$this->render('nameofmy.html.twig', array('latitude' => X, 'longitude' => Y, 'accuracy' => Z);in the controller action.