RefData

RefData is my first open source library for the Elixir eco-system. The idea is that you can create and easily reuse reference/lookup data for you Phoenix projects without any database infrastructure. It is for data that is generally used for the presentation layer rather than complex SQL queries. I have provided some demo code below.

Phoenix.HTML.select

The example below shows a standard list of values for a dropdown box.

Data
ref_data/gender.json

{
    'gender': ['Male', 'Female']
}

Code
my_page.html.eex

select(form, :role, MyRefData.get('gender'))

Result

The example below shows the results for grouped data.

Data
ref_data/countries.json

{
    'countries':
    [
        { 'Asia': ['Australia', 'New Zealand']},
        { 'Americas': ['Canada', 'USA']}
    ]
}

Code
my_page.html.eex

select(form, :role, MyRefData.get('countries'))

Result

The example below shows the results for data with disabled values.

Data
ref_data/gender.json

{
    'gender': ['Male', 'Female']
}

Code
my_page.html.eex

select(form, :role, MyRefData.get('gender', disabled: ['Male']))

Result