Skip to content

sliemeobn/elementary-htmx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElementaryHTMX: Hypertext web apps with Swift

Ergonomic HTMX extensions for Elementary

import Elementary
import ElementaryHTMX

form(.hx.post("/items"), .hx.target("#list"), .hx.swap(.outerHTML)) {
    input(.type(.text), .name("item"), .value("New Item"))
    input(.type(.submit), .value("Add Item"))
}

div {
    button(.hx.delete("items/\(item.id)")) { "" }
    item.text
}

MyFragment(items: items)
    .attributes(.hx.swapOOB(.outerHTML, "#list"))

Play with it

Check out the Hummingbird example app.

Check out the Vapor example app.

Documentation

The package brings the .hx syntaxt to all HTMLElements - providing a rich API for most HTMX attributes.

There is also a ElementaryHTMXSSE module that adds the .sse syntax for the Server Sent Events extensions.

Future directions

  • Add module for WebSockets extension
  • Add module (or separate package?) for HTMX Request and Response headers

PRs welcome.