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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Access to .yaml in a .js

Started by Mick 8 years ago · 3 replies · 887 views
8 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
8 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, 5 years ago
13 1139 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 137 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 112 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 131 7 months ago