exhtml v0.3.1 Exhtml
Exhtml serves HTML contents. It fetches content from backend storage and saves in its state. HTML contents are responded to user directly from state.
Examples:
iex> Exhtml.start []
...> #update
...> Exhtml.update_content(:foo)
"default_content_for_foo"
iex> # get
...> Exhtml.get_content(:foo)
"default_content_for_foo"
Summary
Functions
Deletes the content from a host
Gets html content from a host
Sets html content to a host with a slug
Sets the content fetcher.
A content fetcher is used when Exhtml.update_content/1
is called.
You can pass a function or module as content fetcher
Fetchs and sets the content from the storage to a host’s table
Types
Functions
Deletes the content from a host.
slug
is the key of content.
Returns :ok
.
Examples:
iex> Exhtml.start []
...> Exhtml.set_content :foo, :bar
...> Exhtml.get_content :foo
:bar
iex> Exhtml.delete_content :foo
:ok
iex> Exhtml.get_content :foo
nil
Gets html content from a host.
slug
is the key of content to get.
Examples:
iex> Exhtml.start []
...> Exhtml.set_content(:foo, :bar)
...> Exhtml.get_content(:foo)
:bar
Sets html content to a host with a slug.
slug
is the key of content.value
is the content.
Returns :ok
.
Examples:
iex> Exhtml.start []
...> Exhtml.set_content(:foo, :bar)
...> Exhtml.get_content(:foo)
:bar
Sets the content fetcher.
A content fetcher is used when Exhtml.update_content/1
is called.
You can pass a function or module as content fetcher.
Returns :ok
.
Examples:
iex> Exhtml.start []
...> Exhtml.set_content_fetcher(fn slug -> "Hi, #{slug}!" end)
:ok
iex> Exhtml.update_content(:foo)
"Hi, foo!"
iex> Exhtml.get_content(:foo)
"Hi, foo!"