Skip to content

abitdodgy/ex_component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExComponent

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

include ExComponent

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

alert :primary, "Alert!"
#=> <div class="alert alert-primary">Alert!</div>

alert :primary, "Alert!", class: "extra"
#=> <div class="alert alert-primary extra">Alert!</div>

alert :success, "Alert!"
#=> <div class="alert alert-success">Alert!</div>

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

alert :primary, class: "extra" do
  "Alert!"
end
#=> <div class="alert alert-primary extra">Alert!</div>

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:

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

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ex_component.

About

A DSL for generating HTML components in Elixir

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages