MDL 0.1.8 is a release focused on two things:
- Making hypermedia workflows easier to see and copy.
- Making the npm CLI package easier to inspect and trust.
MDL is a small authoring language for building clean HTML without writing raw
HTML by hand. You write .mdl files, regular CSS, and optional JavaScript; the
CLI checks, builds, and serves the project.
.mdl -> structure and content
.css -> layout and design
HTML -> compiler output
New: Complete htmx Example App
This release adds a complete htmx example under:
examples/htmx
The app demonstrates MDL behavior attributes compiled through the htmx
adapter. Instead of writing raw hx-* attributes in MDL source, you describe
the intent:
form@api(get /api/search)@result(searchResults)@swap(inner)@trigger(input)@loading(searchBusy):
field:
label@for(searchQuery):
Search cookbook entries
.input@id(searchQuery)@name(q)@type(search)@placeholder(Type card, form, swap, or history)
status@id(searchBusy)@class(indicator):
Searching.
With the htmx adapter enabled, MDL emits the corresponding hx-* output:
<form
class="mdl-form"
hx-get="/api/search"
hx-target="#searchResults"
hx-swap="innerHTML"
hx-trigger="input"
hx-indicator="#searchBusy">
</form>
The example app includes:
- live search
- todo list swaps
- cart updates
- profile form validation
- out-of-band toast updates
- request indicators
- disabled submit buttons
- parameter filtering
- request timeouts
- sync behavior
- prompted requests
- preserved islands
- boosted safe forms
Run the API server:
node examples/htmx/server.mjs
In another terminal:
target/debug/mdl serve examples/htmx
Then open:
http://127.0.0.1:4010
The example uses htmx 2.0.10 from a pinned CDN URL in mdl.json, and you can
vendor that script locally if you want an offline demo.
Behavior Adapters
MDL now has a clearer adapter story:
{
"behavior": {
"adapter": "htmx",
"version": "2"
}
}
Supported behavior adapters are:
-
static: normal HTML behavior where possible. -
mdl:data-mdl-api-*attributes for future MDL runtimes. -
htmx: validatedhx-*output for htmx v2.
The important bit is that MDL source stays framework-neutral. You write
attributes such as:
@api(post /api/profile)
@result(profileResult)
@swap(replace)
@trigger(submit)
@loading(profileBusy)
@select-oob(toast)
@request(timeout=5000)
@sync(profileForm:queue-last)
@validate(true)
The adapter decides how that intent becomes HTML.
Safer npm Package
The npm package is also hardened in this release.
@tosiiko/mdl ships a small Node launcher and prebuilt Rust binaries for
supported platforms. That is convenient, but native binaries deserve a clear
audit trail.
0.1.8 adds:
-
SECURITY.mdin the npm package -
BINARY-PROVENANCE.mdin the npm package -
SHASUMS256.txtin the staged public package - runtime checksum verification before executing the selected binary
- explicit
shell: falseprocess spawning in the launcher - provenance-enabled GitHub publishing with
npm publish --provenance
The package still has:
- no runtime npm dependencies
- no npm lifecycle or install scripts
- no install-time binary downloads
- no runtime binary downloads
The launcher selects a binary from vendor/<platform>/, verifies its SHA-256
checksum when SHASUMS256.txt is present, and only then starts the CLI.
Portable Static Builds
This release also includes routing.links in mdl.json.
Use root links when deploying from a site root:
{
"routing": {
"links": "root"
}
}
Use relative links when publishing dist/ under a subfolder or opening the
generated files directly:
{
"routing": {
"links": "relative"
}
}
Relative mode rewrites local page and asset links so the output is easier to
move between static hosts.
Try MDL
Install locally in a project:
mkdir my-mdl-site
cd my-mdl-site
npm install @tosiiko/mdl
npm exec -- mdl init
source bin/activate
mdl serve
Or install globally:
npm install -g @tosiiko/mdl
mdl new my-mdl-site
cd my-mdl-site
mdl serve
Useful commands:
mdl check
mdl format --check
mdl build
mdl serve
Links
- Website: https://getmdl.site
- Repository: https://github.com/tosiiko/mdl-code
- npm package: https://www.npmjs.com/package/@tosiiko/mdl
- htmx examples:
examples/htmx
MDL is still early, but 0.1.8 makes the project much easier to evaluate: you
can inspect the generated HTML, run a real htmx example, check the package
contents, and build static output that fits more hosting setups.
Top comments (0)