Fl4m3Ph03n1x
How to replace deprecated ~E sigil with ~H in Phoenix render funciton
Background
In my quest to learn Phoenix LiveView I found myself using a render function that uses a deprecated sigil:
def render(_assigns) do
~E"""
<menubar>
<menu label="<%= gettext "File" %>">
<hr/>
<item onclick="quit"><%= gettext "Quit" %></item>
</menu>
<menu label="<%= gettext "Extra" %>">
<item onclick="browser"><%= gettext "Open Browser" %></item>
</menu>
</menubar>
"""
end
Now, I understand this is a safe for to use eex code inside of Elixir. However the compiler says I should replace it with ~H. So my firs try is the following:
def render(assigns) do
~H"""
<menubar>
<menu label="{@gettext('File')}">
<hr/>
<item onclick="quit"><%= gettext "Quit" %></item>
</menu>
<menu label="{@gettext 'Extra'}">
<item onclick="browser"><%= gettext "Open Browser" %></item>
</menu>
</menubar>
"""
end
Which does not work and does not show the text properly in the menu:
Quesion
What am I doing wrong?
Marked As Solved
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
I’m not sure why gettext has the @ infront of it. Did you try label={gettext("Extra")}?
2
Also Liked
Bumppoman
The <% %> is not deprecated, it just can’t be used in tag attributes. It’s perfectly fine (and the only way) to use these to interpolate Elixir values into the HTML.
4
cblavier
You should remove the extra double-quotes around braces.
<menu label={@gettext('File')}>
1
Popular in Questions
How to bind a phoenix app to a specific ip address?
could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone.
What strikes me is th...
New
Other popular topics
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










