Silk
Silk is a lightweight Elixir DSL for generating HTML in a clean, expressive, and composable way - using just Elixir syntax.
Features
- Elixir-style HTML generation with blocks.
- Supports standard and void HTML tags.
- Compile-time HTML construction using macros.
Silk is a great fit for:
- Generating dynamic HTML fragments in scripts or apps
- Writing small UI components without reaching for a full template engine
- Keeping everything in Elixir, especially in tooling, testing, or LiveView helper contexts
Installation
def deps do
[
{:silk_html, "~> 0.1.0"}
]
endUsage
Start by importing the Silk module and using the tag macro:
import Silk
tag :section, class: "content" do
tag :h1, do: "Welcome"
endDynamic content? No problem:
import Silk
tag :ul do
Enum.map ["one", "two", "three"], fn item ->
tag :li, do: item
end
endVoid tags like img, br, or input:
tag :img, src: "/logo.png", alt: "Logo"
````
# License
Silk is released under GPL-3.0 - See the [LICENCE](LICENSE).