stefanchrobot
Anyone else excited for the upcoming changes in Phoenix 1.7? ![]()
Looks like phoenix_view is getting deprecated in favour of phoenix_template:
With Phoenix.LiveView, Phoenix.View has been replaced by Phoenix.Component. Phoenix.Component is capable of embedding templates on disk as functions components, using the embed_templates function. For example, in Phoenix v1.7+, the YourAppWeb.UserView above would be written as:
defmodule YourAppWeb.UserHTML do
use YourAppWeb, :html
embed_templates "users"
end
The benefit of Phoenix.Component is that it unifies the rendering of traditional request/response life cycles with the composable component model provided by LiveView.
Replace use MyApp, :view by use MyApp, :html and invoke embed_template “../templates/my”. Alternatively, you can move both the HTML file and its templates to the controllers directory, to align with Phoenix v1.7 conventions.
More details here.
Not sure what exactly are the 1.7 conventions, but I’m guessing this is the recurring idea of colocating controller, view and templates.
I have a non-trivial app that uses Phoenix views (“dead views”; non-live views). I’ve adopted the colocating approach and recently did full migration to Phoenix.Component-based views. My view macro is basically this:
def view do
quote do
use Phoenix.View,
root: "lib/myapp_web",
namespace: MyAppWeb
# x- prefix for Alpine.js
use Phoenix.Component, global_prefixes: ["x-"]
import MyAppWeb.Components
import Heroicons.LiveView
# ...
end
end
I believe that Phoenix is really pushing the boundaries of modern web apps, including traditional request-response ones. Amazing stuff ![]()
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sergio
I’m just excited for 1.7 - hope it drops soon!
AstonJ
Me three! Maybe we should place our guesses on when we might see it?
knoebber
Verified routes!
derpycoder
I have been eyeing Milestone, for Phoenix Framework, every day:
It’s currently at 79%!!
I might end up listing every feature.
cvkmohan
Phoenix 1.7 and LiveView 0.18 ETA? - #6 by cvkmohan here I have predicted 2 weeks for both LiveView 0.18 and Phoenix 1.7. LiveView became a reality in two weeks - however, I got the date for Phoenix completely wrong.
Though we may never know the internal planned date by @chrismccord and @josevalim - my suspicion is they added more features to Phoenix as an afterthought into the current version - hence the delay.
In @chrismccord talk at elixir conf - he said merging/removing layouts as a roadmap item - but - it is getting delivered in this release.
Anyway, all excited to receive the new release.
PS: I initially wrote
Phoenix is delayed- on re-reading I realized it is offensive. The problem is with my anticipation - not with the release date - because there was no commitment on any date.knoebber
its 100% now!
sodapopcan
On top of everything else, I’m really looking forward to phx_gen_auth generating live views. I’m prototyping a new project and was not looking forward to doing the conversion myself yet again. Many thanks and much appreciation to @bemesa21 for doing all that work.
cpgo
I’m still not sure why the devs went with a sigil instead of a function/macro.
Something like
r("some_route/:id", %{id: id})to avoid manual string concatenations with the plus side of making it really easy to grep/search and replace.In the end I cant say I will miss the router helpers as they are today
LostKobrakai
With having the parameters separate you either can’t put in a map like this
r("some_route/:id", map)or you won’t have compile time error messages around missed keys.derpycoder
Changelog for Phoenix got updated a bit:
https://github.com/phoenixframework/phoenix/blob/cffc23049dc82521fe3ff0607fcab6e6ce179688/CHANGELOG.md