The solution I've resorted to, which I feel is less hacky than including 
hidden inputs or anchors is including a global variable that includes the 
paths I need on in the particular template.

e.g., in my index.html.twig:

{%extends '::base.html.twig' %}
<!-- bunch o' html -->
{% javascripts
    '@MyBundle/Resources/public/js/myjs.js'
%}
    <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
<script type="text/javascript">
    var JSON_URLS = {
        getServerStatus: '{{ path("MyBundle_GetStatus") }}', // on dev = 
/app_dev.php/getStatus on live = /getStatus
        foo: '{{ path("_foo") }}',
        bar: '{{ path("_bar") }}'
    };
</script>

Then in myjs.js you would have some code like:

$.get(window.JSON_URLS.getServerStatus, function() {...});

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to