mario-mazo

mario-mazo

Reading programming phoenix with phoenix 1.6

Hello people

I began reading programming phoenix which is for phoenix 1.4 but Im using phoenix 1.6.
I found in chapter 3

At this point, it’s worth emphasizing that a view in Phoenix is just a module, and templates are just functions.
Chris McCord, Bruce Tate, José Valim. Programming Phoenix ≥ 1.4 (Kindle Locations 1846-1847).

​iex> ​ view = 
RumblWeb.UserView.render(​ " ​​ user.html" ​, ​ user: ​ user) ​ {:safe, [[[[["" | "<strong>"] | "José"] | "</strong> ("] | "1"] | ")\n"]} ​ ​ ​ 

iex> ​ Phoenix.HTML.safe_to_string(view) ​ "<strong>José</strong> (1)\n" 

but when I execute this in 1.6 i get

iex(2)> view = RumblWeb.UserView.render("user.html", user: user)
%Phoenix.LiveView.Rendered{
  dynamic: #Function<2.48691599/1 in RumblWeb.UserView."user.html"/1>,
  fingerprint: 180091408340993206255584356524086951088,
  root: false,
  static: ["\n<b> ", " </b> (", ")\n"]
}

I see I can do view.dynamic.("foo") and I get the ["jose", "1"]

But I im just lost… whats going on now? and is there a way to do Phoenix.HTML.safe_to_string in 1.6?

thanks

Most Liked

AlchemistCamp

AlchemistCamp

One thing I highly recommend when going through tutorials is to use the same version of the software the tutorial uses.

It will save you a lot of time with headaches or questions like this. The short answer is now you’re looking at something related to LiveView, which didn’t exist in Phoenix 1.4.

After completing the tutorial or book, you’ll have a better understanding than you did going in and will be in a much better position to upgrade your app, following the upgrade guides that come with releases.

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&amp;query=perfume&amp;page=2, I would like to get: ...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: &lt;h1&gt;Create Post&lt;/h1&gt; &lt;%= ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

Other popular topics Top

greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement