Soarsoft Web DSL - Alpha v0
This page is generated by the Soarsoft Web DSL
Benefits
A concise, pragmatic DSL that mirrors HTML while preserving Kotlin compile-time safety.
- Resembles real HTML - Tag names and nesting match the platform, so translating to and from HTML is straightforward.
- Completely typesafe - Builders enforce valid content models and structure at compile time.
- Transparent content handled cleanly - Mix text and child elements without awkward wrappers or sentinel nodes.
- Easy to extend - Add tags and utilities as small, composable functions without generators or reflection.
- Canonical text nodes - Plain strings become text nodes consistently, avoiding rendering surprises.
Preview of current DSL (v0)
| html {
| head {
| title { "Hello World" }
| }
| body {
| h1 { "Hello World" }
| div { ... }
| p { span { "Hello World" }; a { "Link" }; "Text"}
| }
| }
Current state and limitations
What works today and what's still missing.
- Most common elements implemented - Headings, paragraphs, lists, images, and other essentials for typical pages.
- Basic transparent element support - Mixed text/inline content works for common containers.
- No attribute support - Attributes like class, id, href, and src are not yet available.
- No style DSL - CSS is authored as raw text within a style block.
- No script DSL - Scripts are inserted as raw text; no builder API yet.
Production goal DSL structure (v4)
| html {
| head {
| title { "Hello Once Again" }
| style { ... } // Using a stylesheet DSL
| meta(charset = "UTF-8") // Attributes are named parameters
| meta(name = "viewport", content = "width=device-width, initial-scale=1.0")
| link(rel = "stylesheet", href = "/assets/main.css")
| }
| body {
| div(id = "root") { ... }
| div(classes = { "big" + "rounded" }) { ... }
| a(href = "https://soarsoft.co", target = "_blank") { ... }
| br // [br, linebreak, br()] all possible
|
| // The `attrs` parameter will allow for more complex attribute setting
| script(attrs = { defer; module; async }, src = "/assets/main.js") { ... }
| }
| }
v4 goals
Major milestones planned for a production-ready release.
- Global attributes added - Support common attributes across tags (e.g., id, class, hidden, style).
- Required attributes added - Enforce presence of must-have attributes at compile time for specific elements.
- Custom attributes via named parameters - Provide a flexible way to pass well-typed attributes without stringly-typed maps.
- Attribute DSL with attrs parameter - A composable builder for complex attribute sets (e.g., data-*, ARIA, boolean flags).