Coherence v0.3.1 Coherence.ViewHelpers

Helper functions for Coherence Views.

Summary

Functions

coherence_links(conn, which, opts \\ [])

Create coherence template links.

Generates links if the appropriate option is installed. This function can be used to:

  • create links for the new session page :new_session
  • create links for your layout template :layout

Defaults are provided based on the options configured for Coherence. However, the defaults can be overridden by passing the following options.

Customize the links

:new_session Options

  • :recover - customize the recover link (Forgot your password?)
  • :unlock - customize the unlock link (Send an unlock email)
  • :register - customize the register link (Need An Account?)
  • :confirm - customize the confirm link (Resend confirmation email)

:layout Options

  • :list_tag - customize the list tag (:li)
  • :signout_class - customize the class on the signout link (“navbar-form”)
  • :signin - customize the signin link text (Sign In)
  • :signout - customize the signout link text (Sign Out)
  • :register - customize the register link text (Need An Account?)

Disable links

If you set an option to false, the link will not be shown. For example, to disable the register link on the layout, use the following in your layout template:

coherence_links(conn, :layout, register: false)

Examples

coherence_links(conn, :new_session)
Generates: Forgot your password?  Send an unlock email Need An Account? Resend confirmation email

coherence_links(conn, :new_session, recover: "Password reset", register: false
Generates: Password reset  Send an unlock email

coherence_links(conn, :layout)             # when logged in
Generates: User's Name  Sign Out

coherence_links(conn, :layout)             # when not logged in
Generates: Need An Account?  Sign In
coherence_path(module, route_name, conn, action)

Helper to avoid compile warnings when options are disabled.

coherence_path(module, route_name, conn, action, opts)
confirmation_link(conn, text \\ "Resend confirmation email")
confirmation_link(conn, user_schema, text)
current_user(conn)
invitation_link(conn, text \\ "Invite Someone")
logged_in?(conn)
recover_link(conn, text \\ "Forgot your password?")
recover_link(conn, user_schema, text)
register_link(conn, text \\ "Need An Account?")
register_link(conn, user_schema, text)
required_label(f, name, opts \\ [])
signin_link(conn, text \\ "Sign In")
signout_link(conn, text \\ "Sign Out", signout_class \\ "")
unlock_link(conn, text \\ "Send an unlock email")
unlock_link(conn, user_schema, text)