Can I use p-sigil in H-sigil?

Can I use the new p-sigil in a H-sigil?

defmodule MyProjectWeb.Navbar do
  use Phoenix.Component

  def navbar(assigns) do
    <div class="navbar bg-primary">
      <a href={~p"/"}>Home</a>

When I do this I get a compile error

β€œ(CompileError) undefined function sigil_p/2 (expected MyProjectWeb.Navbar to define such a function or for it to be imported, but none are available)”

Am I doing something wrong, or is this not possible?

1 Like

You’re not importing the verified routes module. Phoenix.Component does not include sigil_p.

Switch from

use Phoenix.Component


use MyProjectWeb, :html

This should get you working. The MyProjectWeb.html macro imports everything you need.

1 Like

Oke, Thanks! This worked, going through the macro also helped me better understand