How to properly use case statements in EEx (LiveView)

Totally unrelated to your question, but…

…Try “Surface”! It changed my life! :smile:

You can take each of those big groups of HTML, slap them in a “component” and then you insert something like a “fake html” tag into the code. The tag gets inflated into the contents of the component.

Now at this point you are correct in pointing out this is no different to using a partial. However, the syntax is similar to adding new HTML tags, so this also implies that the content of the tag gets passed in kind of like a param into the partial function.

I use it by creating a component say “BoilerPlate”, which is the outline of the form, it only contains components like “SideBar”, “TopNav” and “Content”. These inflate to their own components and so on. Content will be the wrapped content, which in your case will be one of several components, decided by the results of the case statement.

I’m then creating a folder with the same name as the component and further break that main content down into a small enough number of pieces that it’s understandable. I really like it!

2 Likes