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
- Host: GitHub
- URL: https://github.com/abitdodgy/ex_component
- Owner: abitdodgy
- Created: 2020-04-07T21:28:46.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-23T02:37:04.000Z (almost 6 years ago)
- Last Synced: 2025-10-21T14:56:44.538Z (8 months ago)
- Topics: components, components-library, dsl, elixir
- Language: Elixir
- Size: 71.3 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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).