nesimtunc
Hello everyone,
I’m seeking help in converting the following HTML code snippets into the new HEEx template format:
<dd class="descp" lang='<%= (if v.lang_code == "a", do: "b", else: "c")%>'><i><%= v.descp %></i>
</dd>
<meta property="al:ios:url" content='myapp://<%= if(@conn.assigns[:query], do: "w/" <> @conn.assigns[:query], else: "") %>'/>
In old version we used to do like this:
<meta name="keywords" content='bla bla <%= if(@conn.assigns[:query], do: @conn.assigns[:query], else: "") %>'/>
But now I can do this like this according to the doc, but it doesn’t seem convenient for me.
<% keywords = "bla bla" %>
<% if @conn.assigns[:query] do %>
<% keywords = keywords <> @conn.assigns[:query] %>
<% end %>
<meta name="keywords" content='@{keywords}'/>
So, tell me the best practice please ![]()
Thank you in advance!
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
lubien
How about:
and on your core components:
aiwaiwa
So
content={if true, do: "this", else: "that"}does not work for you?nesimtunc
Can we do this in HTML template file?
nesimtunc
I think I could manage like this:
However due to conditional HTML tag the compiler thinks it’s not closed, so, it won’t compiler at the moment.
Error:
== Compilation error in file lib/ferhengco_web/views/layout_view.ex ==
** (Phoenix.LiveView.HTMLTokenizer.ParseError) lib/myapp_web/templates/layout/_menu.html.heex:12:5: missing opening tag for
We know it will be open and close eventually when it’s rendered, but why compiler can’t understand this? Previously, before upgrade to live view it was working fine like this.
I’m thinking to move a
liitem to a variable and use in both case within<ul>@{langs}</ul>Is there a better way to do this?
chrismccord
You need to use
{}for the dynamic expression like @lubien first showed:nesimtunc
I must tell @chrismccord sensei but I don’t like this syntax
Thank you!
I’m able to compile only this way, I get this visual error in VSCode, not sure which extension is showing this though.
Single Quote
Doube Quote
LostKobrakai
You don’t need to wrap an outer condition in a string. Within
attr={…}any elixir expression is allowed.id={nil}won’t render the attribute, but won’t cause any issues, so you can also skip theelsepart of theif.aiwaiwa
Feels like you have some mismatched parenthesis somewhere. May be outdated plugin
Which, as @LostKobrakai points out, can be simplified as interpolation is indeed unnecessary (in first case)
But both work for sure
nesimtunc
This way is much better and it works!
But with same plug-in error. Which plug-in do you use? I’m using these ones:
aiwaiwa
.vscode/settings.json:Some great hex plugins: