How to declarate js variable into global scope from twig template?

I have twig template with that:

<script type="text/javascript">
  var initParams = {
    homePage: '{{ url('_homepage') }}'
  };
</script>

On other hand, i have .js file with usage of initParams.homePage. The problem is PHPStorm think that my initParams is not defined. Is there the way to send defination of inTwig js variables to global PHPStorm scope?

Thanks in advance!

1 comment
Comment actions Permalink

see https://youtrack.jetbrains.com/issue/WI-3696 - each "injected" fragment is currently a separate virtual document, so variables declared in such fragments are only 'visible' inside them

0

Please sign in to leave a comment.