Sebb
How do you set classes in heex?
I use sth like solid’s classList
<div class={class_list(%{
"these classes are always included" => true,
"these only when foo is 0" => @foo == 0,
"only when bar aint baz" => @bar != "baz"
})
}>
def class_list(map) do
map
|> Enum.filter(fn {_, include?} -> include? end)
|> Enum.map(fn {class, _} -> class end)
|> Enum.join(" ")
end
thats OK, but it would be nice if we could do
<div class_list={%{
"these classes are always included" => true,
"these only when foo is 0" => @foo == 0,
"only when bar aint baz" => @bar != "baz"
}}
>
What are some other approaches?
Most Liked
LostKobrakai
<div class={[
"these classes are always included",
if(@foo == 0, do: "these only when foo is 0"),
if(@bar != "baz", do: "only when bar aint baz")
]}
>
4
LostKobrakai
4
Popular in Discussions
Hello everyone,
I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
Hi everyone, im working on find best language/framework/system for
high concurrency, high performance and stable performance
after wor...
New
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
I would like to spark a discussion about the static access operator: ..
For whom does not know: it is used in Elixir to access fields of...
New
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New
I’m playing with Elixir - It’s fun. I think @rvirding does give Elixir courses these days.
Re: files and database - when I given Erlang ...
New
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
Other popular topics
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
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
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Got a question about when to concat vs. prepending items to list then reversing to achieve appending.
So i know lists boil down to [1 | ...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
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








