How to display accented letters in Phoenix's template via the `assigns` map?

The title is self explanatory. Using the following controller:

 def index(conn, _params) do
    render(conn, "index.html", %{myvar: 'héhé'})
 end

the accented letters are not displayed correctly with the following template:

<div>
  <%= @myvar %>
</div>

However, accented letters directly written in the template are displayed correctly. Maybe some processing is done to the assigns map ?

Charlist?

3 Likes

Use "" not ''. https://elixir-lang.org/getting-started/binaries-strings-and-char-lists.html

5 Likes