Call a global twig function in external script in symfony

I have a datatable on my page which is rendered using a js file which is included in twig page.
On the datatable i need to provide a dynmaic link to other page which has parameters in the url.
My problem is i need to encrypt the paramters passing through the url.

I already created a service and included in the twig.yaml as global variable as

    default_path: '%kernel.project_dir%/templates'
        crypto: '@AppServiceCrypto'

I can access the functions in the crypto service from a twig as

 var cryptoCall = '{{crypto.encrypt('__ID__')}}';

But i need to call this in my external js to encrypt the id which is getting when i am rendering the datatable.
Is there any possible way to achieve this.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *