bartblast

bartblast

Creator of Hologram

Navigating between LiveView and Hologram pages

This question was moved from another thread because I thought it deserved its own discussion:

Most Liked

bartblast

bartblast

Creator of Hologram

From LiveView → Hologram:

To generate the path for a specific Hologram page, you can use the Hologram.Router.Helpers functions. These are automatically imported in Hologram Component and Page modules, but you can also import them in your LiveView:

  • page_path/1 - e.g., page_path(MyPage)
  • page_path/2 - e.g., page_path(MyPage, a: 1, b: "xyz")

The second parameter in page_path/2 can be either a keyword list or a map.

These helpers are currently not documented because they’re mostly used internally, but they may be needed in a gradual migration scenario, so maybe it’s time to surface them more prominently in the docs.

From Hologram → LiveView:

Just use a regular <a> element with href pointing to the LiveView route.

If you’re worried about “zombie” link prevention (for when routes change and you forget to update them) and want to verify what you wrote is correct - which is what the ~p sigil gives you - you can use the ~p sigil on the server side, e.g., in init/3, and save it to the component/page state, then use it as a variable in the Hologram template.

Important note: In both cases, a full HTTP request will be needed to transition from one world to the other.

frankdugan3

frankdugan3

Semi-related to this, I’m curious what would be idiomatic in an app that had both LiveView pages and Hologram pages. Would ~p be appropriate to use to go from Hologram to LV? And what would be idiomatic for LV to Hologram? :thinking:

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
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
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
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
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
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
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
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

We're in Beta

About us Mission Statement