<ul>
<%= if function_exported?(Routes, :live_dashboard_path, 2) do %>
<li><%= link "LiveDashboard", to: Routes.live_dashboard_path(@conn, :home) %></li>
<% end %>
</ul>
How do I comment out the part between the <ul> tags?
<.ignore>
<ul>
<%= if function_exported?(Routes, :live_dashboard_path, 2) do %>
<li><%= link "LiveDashboard", to: Routes.live_dashboard_path(@conn, :home) %></li>
<% end %>
</ul>
</.ignore>
Or you can use Surface and then you get {!-- ... --}
They say you can lead a person to a module, but you can’t make them import funtions. You’ll probably want it imported along with the live_view and live_component helpers, and unless you define your own component helper (these are the functions called when you use CheeseWeb, :live_view etc.), you’ll have to import it manually if you’re in a module that just uses Phoenix.Component. I presume your app is for Cheese.
defmodule CheeseWeb.Helpers do
use Phoenix.Component
def ignore(_assigns), do: ""
end
and you’ll have something like this in cheese_web.ex:
def live_view do
quote do
use Phoenix.LiveView,
layout: {CheeseWeb.LayoutView, "live.html"}
unquote(view_helpers())
end
end
so go down to defp view_helpers do and import your Helpers module.
defp view_helpers do
quote do
# Use all HTML functionality (forms, tags, etc)
use Phoenix.HTML
# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
import Phoenix.LiveView.Helpers
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
import CheeseWeb.ErrorHelpers
import CheeseWeb.Gettext
import CheeseWeb.Helpers <------------------------- add this
alias CheeseWeb.Router.Helpers, as: Routes
end
end