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') }}'

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 - each "injected" fragment is currently a separate virtual document, so variables declared in such fragments are only 'visible' inside them


Please sign in to leave a comment.