Can i retrieve the global parameters in file javascript?
i have for example
twitter.app_secret: my_token
how can i retrieve it in file Javascript ?
for now i use this
<script type="text/javascript">
    var app_assoluto = '{{ app.request.getSchemeAndHttpHost() }}';
    var consumer_key_twitter = '{{ twitter_app_id }}';
    var consumer_secret_twitter = '{{ twitter_app_secret }}';
    var access_token_twitter = '{{ twitter_access_token }}';
    var access_token_secret_twitter = '{{ twitter_token_secret }}';
    var facebook_app_id = '{{ facebook_app_id }}';
    var env = '{{ app.environment }}';
</script>
also parameters like {{ app.request.getSchemeAndHttpHost() }}
there is a better solution for retrieve this param??
I noticed that you are use twig templates. So, you can make your parameters as twig globals like that:
# app/config/config.yml
twig:
    # ...
    globals:
        key: "%your_value%"
And in your templates you have access to key via {{ key }}
UPDATE
If you are using jQuery, you can do that in this way:
# template.html.twig
<script>
    var params = params || {};
    $.extend(params, {
        twitterAppId: '{{ twitter_app_id }}'
    });
</script>
and in your JS file:
# script.js
(function() {
    params = params || {};
    twitterAppId = params.twitterAppId ||{};
)();
I hope that this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With