Created
October 13, 2019 23:19
-
-
Save piotrpog/1fbf8111dd880c3ff962e7b8fab96938 to your computer and use it in GitHub Desktop.
Twig macro for passing Twig variables into Javascript. More info: http://craftsnippets.com/articles/using-javascript-in-twig-templates-with-craft-cms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro jsVar(variable, jsVariableName) %} | |
{# v1 #} | |
var {{jsVariableName}} = {{variable|json_encode|raw}}; | |
{% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment