Hi,
I’ve just got Coherence integrated and working, and now am trying to customize the look of it, in particular the following code that displays links for joining and logging in. They work fine, but I want to display buttons instead. My problem is that I’m trying to work out how to put the href (link) inside the button.
Here’s what appears to be the relevant bit of code from coherence_view_helpers.ex
def coherence_links(conn, :layout, opts) do
list_tag = Keyword.get opts, :list_tag, :li
signout_class = Keyword.get opts, :signout_class, "navbar-form"
signin = Keyword.get opts, :signin, @signin_link
signout = Keyword.get opts, :signout, @signout_link
register = Keyword.get opts, :register, @register_link
if Coherence.logged_in?(conn) do
current_user = Coherence.current_user(conn)
[
content_tag(list_tag, current_user.name),
content_tag(list_tag,
link(signout, to: coherence_path(@helpers, :session_path, conn, :delete, current_user), method: :delete, class: signout_class))
]
else
signin_link = content_tag(list_tag, link(signin, to: coherence_path(@helpers, :session_path, conn, :new)))
if Config.has_option(:registerable) && register do
[content_tag(list_tag, link(register, to: coherence_path(@helpers, :registration_path, conn, :new))), signin_link]
else
signin_link
end
end
end
Here’s my noob attempt at changing it to a button, which is obviously wrong as it outputs the link wrapped within <button></button>
tags and so doesn’t work.
def coherence_links(conn, :layout, opts) do
button_tag = Keyword.get opts, :button_tag, :button
signout_class = Keyword.get opts, :signout_class, "navbar-form"
signin = Keyword.get opts, :signin, @signin_link
signout = Keyword.get opts, :signout, @signout_link
register = Keyword.get opts, :register, @register_link
if Coherence.logged_in?(conn) do
current_user = Coherence.current_user(conn)
[
content_tag(button_tag, profile_link(current_user, conn)),
content_tag(button_tag,
link(signout, to: coherence_path(@helpers, :session_path, conn, :delete), method: :delete, class: signout_class))
]
else
signin_link = content_tag(button_tag, link(signin, to: coherence_path(@helpers, :session_path, conn, :new)))
if Config.has_option(:registerable) && register do
[content_tag(button_tag, link(register, to: coherence_path(@helpers, :registration_path, conn, :new))), signin_link]
else
signin_link
end
end
end
Here’s the full code from the Coherence demo repo:
https://github.com/smpallen99/coherence_demo/blob/master/web/views/coherence/coherence_view_helpers.ex
It’s a super noob question, but there’s a lot of code for me to work through, and although I can pick out lists [] and things, I’m really failing at this.