One thing that stumped me immediately in Phoenix was the implicit
templates/layout/app.html.eex. I’m developing a pretty typical app which is chunked into several sections - a public front-end, the user app itself, an admin area, an API. Having a default central layout doesn’t serve the requirements of this app, so I spent the first little while trying to figure out how to disable it.
What I wound up with was just a plug in the
:browser pipeline, pointing to a private function that disables the default layout. I then deleted
layout_view.ex. Finally, in my controllers, I created a second plug for specifying routes connections to that particular controller.
Whilst this was fairly trivial to do (and I’m not even sure that’s the only - or right - way to go about it), the notion of first disabling the layout and then setting a new one seems a bit like a code smell to my novice Phoenix nose. In other frameworks I’ve worked with, layouts don’t tend to be assumed until explicitly set; I’ve found they’re often not required.
So for my introductory question to this board (and thanks in advance for helping to further my currently very basic understanding of Phoenix!), I’m curious what prompted the design decision to make
LayoutView) an implicit choice? My first instinct was to search Phoenix generated code to look for a specific reference to “app.html”, assuming that I’d just need to comment out the default line to prevent it… but it looks like LayoutView is hard-coded in lib code.
Again, I’m new here so I may be missing something obvious, but this did strike me as a tad opinionated and I’m curious what may have led to it.