The One with a Frontend

Today I spent 2 hours trying to figure out why my template could not be found. So

I had added an index route, a controller with an index function, a view and an index.html file at .../templates/happiness_index and got a Phoenix error telling me to put a template file at .../templates/happiness_index. I checked every file for typos but could not find any. Then I threw everything away (after committing so I could go back to it) and tried using mix phx.gen.html to generate this for me, but wasn’t happy that I needed a context, I wanted this to be just under the app itself, not a layer further down. Using this with --no-context produced something I did not understand and could not compile (I might have made a mistake while deleting the stuff from before, probably not the generator’s fault).

I then asked my mentor what was wrong and he took one tiny look at it and said “It needs to be index.html.eex.” D’oh! Apparently, EEx is the default templating system for Phoenix. I hadn’t really thought about the fact that a template is more than just some HTML, my thought was “There’s nothing embedded here, so I can just use an HTML file.” Ok no, I can’t. And now that the view/controller part compiles without errors, I can finally start doing something. Maybe. We’ll see. At some point I’m going to need to find out how to change the template default, because there is no way I’m going to write .eex files for more than just some dummy code.

Next tasks on my list: - actually (for reals this time) create the possibity to add something inside my application - figure out how to use Slim/Slime for templating - decide which book(s) I’m going to read next (I’ve started reading Atomic Habits (not for work, but I guess it could be useful for work as well), I wanted to start reading Functional Web Development with Elixir, OTP, and Phoenix for weeks now but have never gotten around to it, and I have decided to give The Pragmatic Programmer another go but am unsure whether to read the first edition or wait for the 20th anniversary one) - search for a session idea that I could do at our Open Space tomorrow (while already sitting in the quite nice Berlin office, where this edition of our Open Space is going to take place) - declutter my to-do list for this week

I think I am going to start at the end of this list.