3 ms·
That symfony case makes a bit more sense. Especially in the context of views and layouts. Phoenix view/layout things still confuse me. Never tried learning them
by elcritch 7y ago
That symfony case makes a bit more sense. Especially in the context of views and layouts. Phoenix view/layout things still confuse me. Never tried learning them so I’ve got one global layout view setup on Bulma (or Bootstrap). It works as I’m doing more of an SPA style UI. I set a title using the controller which feels klunky too, like the put_*_layout setup.
Given Elixir templates are functional you probably could create a view “template inheritance” with a single macro. My Bulma library is intended to be pretty basic, but hopefully you see it’s easy to pass an case with sub-blocks.
I wonder if setting up a macro that could take named blocks and inject them into an EEx template might work for your case of including a view-template in a template. That’d be similar to what I’d like in my library, as it’d be nice to remove the extra “case / block” and just have a “template MyProject.Template, do :header -> <H1>Title</H1> end“. Bonus would be that approach would check block names at compile time! Also you should checkout live components. They’re handy for widgets!
- mercer 7y ago> Phoenix view/layout things still confuse me. When I worked through the Programming Phoenix book, for some reason the view/layout thing was what I struggled with most, and even in the years since its only been recently that I feel I have a proper 'grasp' of how it works. I've been scratching my head as to why this, of all things Phoenix, has been tripping me up so much. Maybe it's right at the 'sweet' spot between Rails magic and (often) Phoenix explicitness, while also being the kind of thing that I find myself least interested in 'grokking'?
- elcritch 7y ago> Maybe it's right at the 'sweet' spot between Rails magic and (often) Phoenix explicitness, while also being the kind of thing that I find myself least interested in 'grokking'? Think you nailed it on the head! It's a chore, and there's a bit of implicitness / Rails-style magic involved. Not much mind you, but the implicit naming thing trips me up.
- mercer 7y agoI suppose the good part of the experience is that it taught me, once again, that as soon as I run into issues I should probably go read the docs until I properly understand things, rather than tweak things for a while until they magically work and then move on...