YakobeYak
YakobeYak

Reputation: 555

What is the best way to handle URLs in javascript files called by assetic (symfony2)

I am using assetic in a twig template to include a javascript file from my bundle's public folder. The problem is this JS file has URLs in it to call other pages using jQuery.

How should i handle these URLs? I could write the URLs as absolute paths - but this causes problems between the dev and prod environment, and also makes the application not very portable. What is the best way to do such things?

Upvotes: 1

Views: 288

Answers (1)

Nuno Costa
Nuno Costa

Reputation: 1620

Maybe moving those urls to a configuration file .

that config.js can be generated via twig and contain the proper urls generated from the routing table

Upvotes: 1

Related Questions