The "&" in a query string get replaced with & How to avoid that?

Tags: #<Tag:0x00007fbcb2a29498> #<Tag:0x00007fbcb2a290b0>


When I create a url in an action using something_url(conn, .....%{k1: 1, k2: 22}) – with a query string that is – and pass it to a template and render, the ampersands get rendered as &amp;


I’ve tried raw(..) but it caused an exception: “no function clause matching in Phoenix.HTML.raw/1” as if it weren’t a string

How to get Phoenix to render it as is?


That’s the way it should be done. Ampersands in links should be encoded: <a href="?foo&amp;bar">.

But maybe you have a reason to not do it, so how did you try with raw/1? Can you show?


For note, things like <a href="?foo&bar"> is invalid according to the spec (is it still in html5? I think so) as &bar does not exist, ampersand is the escape character, so if it should be part of the URL then you need to escape & via &amp; to become <a href="?foo&amp;bar">, this is just standard HTML. :slight_smile:


How to make it render &amp; instead of & ?

Just raw(my_url_with_query_string)


I thought you already had it render &amp;?

What is the actual issue here? What is the output you have now and the code? What is the output you want to have?