-
Hey All, I am having an issue passing a string into a hx-header `templ Head(csrf string) { <input id="vdocsearch" name="vaultdocsearch" type="text" class="flex justify-center" onkeyup="debounceSearch()" hx-post="/search" hx-trigger="keyup delay:500ms" hx-target="#results" hx-indicator=".htmx-indicator" hx-headers='{"X-CSRF-Token": { csrf }' class="p-2 border rounded w-full" }` The header isn't being populated and I am not sure why -- when I was reading the docs, it looks like this should work since the input is a string. Thoughts? |
Beta Was this translation helpful? Give feedback.
Answered by
pharrisee
Oct 17, 2024
Replies: 1 comment
-
I'd personally change the hx-headers={ fmt.Sprintf(`{"X-CSRF-Token":"%s"}`,csrf)} String interpolation isn't supported in templ as far as I can see so you'll have to build the string yourself. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zthacker
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd personally change the
hx-headers
line to look something more like this:String interpolation isn't supported in templ as far as I can see so you'll have to build the string yourself.