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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Latest Phoenix Threads
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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: