Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Access to .yaml in a .js

Started by Mick 9 years ago · 3 replies · 1087 views
9 years ago

Hi All,

My need is quite simple but i can't figure it out .

i am using {% do assets.addJs('theme://js/mynice.js') %} and it's well working. I would like to use in my .js my configuration setting.

How can i send or use in mynice.js the configuration setting from site.yaml or system.yaml or theme.yaml ?

Thanks for any help !

👍 1
9 years ago

i got it so i share it :
<script type="text/javascript">
var test= '{{ config.site.test.alert }}';
alert(drole);
</script>

9 years ago

so did you find a working solution)? I have the same problem

9 years ago

Hi,

you can override once loaded

TWIG
script type="text/javascript"> 
var myparameter = '{{ config.theme.myparameter }}';  
-   and just use the  myparameter -
</script>

but finally i don't use it for my personal case.

last edited 02/22/18 by Mick

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by FrViPofm, 4 days ago
5 86 4 days ago
Forms & Blueprints · by Ton Haarmans, 6 years ago
13 2113 7 months ago
Forms & Blueprints · by Hugo Oliveira, 8 months ago
0 597 8 months ago
Forms & Blueprints · by Flachy Joe, 9 months ago
9 690 9 months ago
Forms & Blueprints · by Augustus, 10 months ago
7 737 10 months ago