Skip to content
Grav 2.0 is officially stable. Read the announcement →
Forms & Blueprints

Access to .yaml in a .js

Started by Mick 9 years ago · 3 replies · 1005 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>

8 years ago

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

8 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 Ton Haarmans, 6 years ago
13 1707 6 months ago
Forms & Blueprints · by Hugo Oliveira, 7 months ago
0 346 7 months ago
Forms & Blueprints · by Flachy Joe, 8 months ago
9 456 8 months ago
Forms & Blueprints · by Augustus, 8 months ago
7 469 8 months ago
Forms & Blueprints · by Julien, 8 months ago
10 498 8 months ago