An open API service indexing awesome lists of open source software.

https://github.com/abitdodgy/ex_component

A DSL for generating HTML components in Elixir
https://github.com/abitdodgy/ex_component

components components-library dsl elixir

Last synced: 8 months ago
JSON representation

A DSL for generating HTML components in Elixir

Awesome Lists containing this project

README

          

# ExComponent

A DSL for easily building dynamic, reusable components for your frontend framework in Elixir.

```elixir
include ExComponent

defcontenttag :alert, tag: :div, class: "alert",
variants: [
primary: [class: "alert-primary"],
success: [class: "alert-success"]
]

alert :primary, "Alert!"
#=>

Alert!

alert :primary, "Alert!", class: "extra"
#=>

Alert!

alert :success, "Alert!"
#=>

Alert!

```

Generated function clauses accept a block and a list of opts.

```elixir
alert :primary, class: "extra" do
"Alert!"
end
#=>

Alert!

```

This lib is a work in progress and its API might change.

Please see internal docs for extensive usage examples.

## Installation

The package can be installed by adding `ex_component` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:ex_component, "~> 0.1.0"}
]
end
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/ex_component](https://hexdocs.pm/ex_component).