View Source LiveUI.Formatters (LiveUI v0.1.0)
Functions for controlling how the fields are displayed on the screen.
import LiveUI.Formatters
def index_view(user) do
super(user)
|> add_formatters(
email: {&mask/2, [left: 4]},
bio: &markdown/1,
website: {&link_/1, %{name: "Web"}},
role: &String.capitalize/1
)
end
Adding custom formatter is documented in LiveUI.Protocol.Utils.add_formatters/2
.
Summary
Functions
Renders a copy icon next to the value.
Renders a link with an icon.
Renders markdown as HTML.
Masks a value with asterisks.
Functions
Renders a copy icon next to the value.
def index_view(user) do
super(user)
|> add_formatters(email: &LiveUI.Formatters.copy/1,
end
Attributes
value
(:string
) - field value that will be copied into clipboard.field
(:string
) - field name used as a part of DOM id -copy-<field>
.class
(:string
) - CSS class. Defaults tonil
.
Renders a link with an icon.
def index_view(user) do
super(user)
|> website: &LiveUI.Formatters.link_/1
|> website: {&LiveUI.Formatters.link_/1, %{name: "Website"}}
end
Attributes
name
(:string
) - Defaults to""
.
Renders markdown as HTML.
def index_view(user) do
super(user)
|> bio: &LiveUI.Formatters.markdown/1
end
Masks a value with asterisks.
def index_view(user) do
super(user)
|> add_formatters(email: {&LiveUI.Formatters.mask/2, [right: 4]})
end