stefanchrobot

stefanchrobot

Exciting things cooking up for Phoenix 1.7

Anyone else excited for the upcoming changes in Phoenix 1.7? :fire:

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 :clap:

Most Liked

derpycoder

derpycoder

I have been eyeing Milestone, for Phoenix Framework, every day:

It’s currently at 79%!!


  • I am excited about StoryBook.
  • The new redesigned Tailwind CSS templates, that will get generated.
  • The live auth flow, that will come by default.
  • The new flash slot approach, for modern toast message.
  • Verified Routes.

I might end up listing every feature. :sweat_smile:

16
Post #5
AstonJ

AstonJ

Just noticed this blog post by Chris - haven’t read it yet but it mentions 1.7…

knoebber

knoebber

its 100% now!

11
Post #7

Where Next?

Popular in Discussions Top

scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
kostonstyle
Hi all How can I compare haskell with elixir, included tools, webservices, ect. Thanks
New
sergio
There’s a new TIOBE index report that came out that shows Elixir is still not in the top 50 used languages. It also goes on to call Elix...
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19327 150
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
jer
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement