I got a List in controller:
data = ["one", "two"]
I would love to render it in eex template as:
<script>
var data = ["one", "two"]
</script>
How can I make it, I tried var data = <%= raw(@data) %>, only got var data = [one, two].
Got the answer from this post,
This is how I make it in the last:
<%= raw(Poison.encode!(@data)) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With