silverdr
I’d like to have a generic, abstract (I apologise for the OO terminology
component, which takes care of all the styling and can be rendered by calling its function from specific “subclass instances” providing some additional bits like title, size and the actual content. This seem to work well until I want to change the default @inner_block. It seems to have some structure:
inner_block: [
%{
__slot__: :inner_block,
inner_block: #Function<1.68901124/2 in PhxAppWeb.PageLive.render/1>
}
]
which makes it hardly override-able… or? Is there a way to keep the “default slot” being default but overriding its content when needed rather than using some conditionals?
I understand I can rewrite things and work this around but would like to know that I have to ![]()
Docs are here: Phoenix.Component — Phoenix LiveView v1.2.5
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cpgo
Also interested in this.
I’m playing around with a similar idea on a attempt to make it easier to use HotwireTurbo on phoenix.
For now I have the following hack to reuse a generic component. Not really sure yet what parameters the
inner_blockfunction expects so I’m just ignoring them for now.The idea here is just to wrap an existing template on a
<turbo-stream></turbo-stream>tagLostKobrakai
Can you describe this with a few examples? It’s not really clear why you’d need to alter
inner_block?silverdr
Ane example - let’s say I pass default content inside a component. Something like
The above taken from the docs mentioned above. And in the majority of cases it is OK. F. e.
But on some rare occasions there is something in the queue and needs to be put out. One of the ways to do it would be to override the default content provided in
@inner_block(there is no pubsub involved and the widget does not update itself on change). I understand it is not the only way to do it but would like to know if this is at all feasible.LostKobrakai
What’s wrong with this as the template for
<.queue_widget>?silverdr
The template is currently common for all widgets and is located in the “abstract” one. Specific widgets provide their name, size and default content, which I’d like to override on occasions but want to keep the abstract widget generic so that it doesn’t have to “know” what it is rendering. I can do generic “assign” and use that. That’s what I am now doing but I feel like running in circles around the original idea of just assigning stuff to
@inner_blockLostKobrakai
I think I still don’t know exactly what you’re attempting here. If your abstract components is meant to be abstract, then it shouldn’t be involved in markup at all. It feels a bit strange to try to abstract on one hand and on the other still try to break out of the abstraction.
silverdr
Hmm.. The abstraction means that all things common go there - widget has a bounding box, header, title, some styling, etc. Specific widgets provide values for the variable parameters. At least that’s how I used to do those things. Here I have a function called
widget/1and specific ones likequeue_widget/1which assigns its title, size etc. calling the “abstract”widget/1in the end for rendering the actual outputLostKobrakai
That sounds like slots and overwriting default slot markup would be the solution, but hard so say without code.
silverdr
That’s how I originally thought of doing it. And there should be part assigning the non-default content in
queue_widget/1LostKobrakai
My directly delegating to
widgetas a function I feel like you’re leaving options lying on the ground.<.queue_widget>and<.widget>can have different views on@inner_block.