Skip to content

nutshell-lab/content-spinner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ContentSpinner

Basic implementation of a content-spinner

Installation

The package is not yet available in hex. If you need it please reach out through an issue :)

def deps do
  [
    {:content_spinner, git: "https://github.com/nutshell-lab/content-spinner.git"}
  ]
end

Getting started

Most basic usage :

  iex> ContentSpinner.spin([["Hey there !", "Hello !"], " We are doing content spinning"])
  # "Hello ! We are doing content spinning"

Bring your own data and translations :

    iex> template = ["[", {:now, :iso}, "] : ", ["Hello ", "Hey "], :surname, ", here is your timestamp : ", {:now, :timestamp}]
    iex> data = %{ surname: "Jon" }
    iex> translator = fn
      :surname, passed_data -> passed_data.surname
      {:now, :iso}, _data -> DateTime.utc_now() |> DateTime.to_iso8601()
      {:now, :timestamp}, _data -> DateTime.utc_now() |> DateTime.to_unix()
    end
    iex> ContentSpinner.spin(template, data, translator)
    # "[2022-02-07T09:41:39.500345Z] : Hello Jon, here is your timestamp : 1644226899"

I want more

We are interested. Please reach out :)

About

Tiny content spinning librairy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages