Hi there. I have a js function and i want pass a js variable into the go template string .how can i do this
function test(variable) {
{{ range where .Site.RegularPages "Params.title" "intersect" (slice variable)}}
{{ end }}
}
Hi there. I have a js function and i want pass a js variable into the go template string .how can i do this
function test(variable) {
{{ range where .Site.RegularPages "Params.title" "intersect" (slice variable)}}
{{ end }}
}
If I understand correctly, it may be impossible. Since the go template is executed on build stage, and the JS is executed on browser side after building the site.
If you’re going to show dynamic data, you can save the pages to a file, and then using JS (such as fetch
) to load the pages.
See also