Add a `put_layout {MyAppWeb.LayoutView, "app.html"}` on `MyAppWeb` by default

41 views
Skip to first unread message

kelvin....@gmail.com

unread,
May 26, 2020, 1:44:55 PM5/26/20
to phoenix-core
So, this came from a discussion in here: https://github.com/phoenixframework/phoenix/issues/3865
 
I think even though it would make no actual difference, as if we don't do that, `put_default_views` will do it for us, explicitness would benefit everyone.

I would go even further and actually change the default value of `put_default_views` to `false` in here: https://github.com/phoenixframework/phoenix/blob/f7784f86ed803a39eb45486f0e031e974e708818/lib/phoenix/controller.ex#L173

And also deprecate the use of that option in favor of being explicit on every controller of which view to use. I know it is a breaking change, but it is one that would enforce explicitness and would make the web code less "magic".

kelvin....@gmail.com

unread,
May 26, 2020, 1:48:34 PM5/26/20
to phoenix-core
Going a little bit nuts now: I would even deprecate `put_view`, `put_layout` and `render` macros in favor of being explicit of which layout and which view to use for every render, but maybe that would be too much of a change 😂 

Chris McCord

unread,
May 29, 2020, 1:00:20 PM5/29/20
to phoeni...@googlegroups.com
Every choice is a tradeoff, so it’s up to you to figure out which things you’d like to optimize for.  I think we strike a nice balance today.

--
You received this message because you are subscribed to the Google Groups "phoenix-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-core...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-core/4b05c08c-9888-4cf0-8c7a-66e5b1c8380b%40googlegroups.com.

Chris McCord

unread,
May 29, 2020, 1:00:20 PM5/29/20
to phoeni...@googlegroups.com
The ship has sailed on this possibility, but you are welcome to do it in your applications :)

--
You received this message because you are subscribed to the Google Groups "phoenix-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-core...@googlegroups.com.

Allen Madsen

unread,
May 29, 2020, 4:55:30 PM5/29/20
to phoenix-core
What about adding put_layout and put_view as explicit calls in the generators?

Allen Madsen

unread,
May 29, 2020, 4:58:17 PM5/29/20
to phoenix-core
By generators I meant the controller generator, not the MyAppWeb one.

José Valim

unread,
May 29, 2020, 5:28:03 PM5/29/20
to phoeni...@googlegroups.com
In my opinion it is unnecessary noise once you get familiar with the convention.

The only reason why put_root_layout is not also automatically done is backwards compatibility.

Reply all
Reply to author
Forward
0 new messages