Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Function for transfering variables from Twig to JS #4915
I often pass Twig variables into JS. I do this like this:
This is little cumbersome. I propose simplifying this process with function like this:
This would output:
If second argument would not be provided, js variable name would be same as twig variable name.
If object or array was used instead of simple twig variable, it would be passed through json encode function.
If twig variable was boolean instead of string, function could skip wrapping js variable in