0

I want to add some script to Grav using some parameters.

{% do assets.addInlineJs('var imageurl = "'.{{ url('theme://images/logo.svg') }}.'";', 99) %}

This and some other things like

{% do assets.addInlineJs('var imageurl = "' . url("theme://images/logo.svg") . '";', 99) %}

do not work. What am I missing? I want to use an imagepath from the theme to pass to the script.

campino2k
  • 1,618
  • 1
  • 14
  • 25
  • Did you got this working? I'm having the same issues trying to pass parameters to a function using inlinejs – Goca Jun 08 '17 at 17:46
  • No, I haven't. It may be a possible using the Assets Plugin (https://github.com/getgrav/grav-plugin-assets) but I have not tested it yet. – campino2k Jun 08 '17 at 21:29

1 Answers1

0

To concatenate strings in Twig, you need to use ~ not .

{% do assets.addInlineJs('var imageurl = "' ~ url("theme://images/logo.svg") ~ '";', 99) %}

Sample result:

var imageurl = "/user/themes/my-theme/images/logo.svg";
Hung Tran
  • 790
  • 2
  • 8
  • 24