Skip to content

codacy-badger/exhtml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Exhtml

travis-status Inline docs

Exhtml is a library that handles HTML page serving. There are some benifts to have a dynamic HTML page host rather than static server:

  1. it's easy to deploy a small number of pages.
  2. it's safer to make the HTML server pull content from backend storage than push contents to it.
  3. you can add middlewares as you wish, such as performance monitoring, server-side procsessing, etc..

Installation

If available in Hex, the package can be installed as:

  1. Add exhtml to your list of dependencies in mix.exs:
def deps do
  [{:exhtml, "~> 0.1.0"}]
end
  1. Ensure exhtml is started before your application:
def application do
  [applications: [:exhtml]]
end
  1. (optional) Add configuration into your project:
use Mix.Config

# `content_fetcher` can either be a module or a function
# `MyContentFetcher.fetch` accepts a key and returns content for the key.
config :exhtml,

# use a function in named module as a fetcher:
# content_fetcher: &MyContentFetcher.fetch/1,

# or use an anonymous function:
content_fetcher: fn slug -> "#{slug} content on remote" end,

# where to store contents on disk:
data_dir: "/home/data/exhtml_contents"

Usage

# update content.
# Notice: contents live in memory and automaticly persisted in disk.
Exhtml.update_content :my_page

# later, get content:
Exhtml.get_content :my_page
#=> "my_page content on remote"

Online documents

License

MIT liccense

Contributions

Packages

No packages published

Languages

  • Elixir 100.0%