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

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

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
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
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement