Skip to content
Advertisement

How can i javascript in mustasche

I want to use javascript inside the mustache template. (test.mustache)

https://test.com/?lang=en

<script>
let query = window.location.search;
console.log(query);
</script>

I got ?lang=en with the above code.

{{#cats}}
<a href="{{link}}" class="ui label-lsc" style="background-color: {{wpsc_cat_bg_color}}; color: {{wpsc_cat_color}};">{{{value}}}</a>
{{/cats}}

i in this code I want to append ?lang=en after {{link}}.

Is there any way?

Advertisement

Answer

No, you can’t use JavaScript in your template.

The entire point of the template is to allow code to be extracted. Whatever code is currently executing your template is feeding the template a link variable, which the template is outputting via {{link}}. You need to modify that calling code so that it alters the value of link before it’s passed to the template.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement