Arturo HTML builder DSL. Tags become functions. Text is escaped for you. The result is compact HTML5, ready to print or write to a file.

artruro dsl html html builder html generation html5 serialization zero dependency

html

Write HTML in Arturo. Skip the string juggling.


Arturo logo Arturo logo
~ CODE IS ART ~

Language: Arturo   License   CI Status

At a Glance

import {src/html}!

print html [
  head [title "Hello"]
  body [
    h1.class: "title" "Hello, Arturo!"
    p "HTML without string templates."
  ]
]

Tags become functions. Text is escaped for you. The result is compact HTML5,
ready to print or write to a file. Requires Arturo 0.10.0+; no runtime dependencies.

Quick start · ✨ What's next · API reference · Examples · Migration

✨ Modern & Emerging HTML

Modern interfaces, written in Arturo. Explore customizable selects, location
sharing, camera and microphone controls, and web app installation with dedicated
tag helpers. Bring a little of the web's next chapter to your next interface. ✨

Helper What you can explore
selectedcontent Rich selected-option content in customizable selects
geolocation Browser-controlled location sharing
usermedia Camera and microphone access controls
install A browser-controlled web app install button
permission The earlier generic permission-control experiment

These helpers are available now in the DSL; browser availability varies.
selectedcontent is part of the HTML Living Standard; the capability controls
include experimental proposals. permission is a deliberately retained
experiment that evolved into geolocation and usermedia.
See examples and feature details.

Built for modern HTML. HTML4 and obsolete or deprecated HTML APIs and tags,
such as font, center, and param, are outside our supported API. The
superseded permission experiment above is an explicit exception.

Installation

1.0 release candidate

v1.0.0-rc.1 is a prerelease for feedback before 1.0. The core API intended
to remain compatible throughout 1.x covers html, body, fragment, the
markup DSL object, standard tag helpers, custom elements, attribute
serialization, escaping, and explicit trusted raw content.

Experimental browser tag helpers remain available, but their browser behavior
and underlying proposals may change. They are not a promise of browser support.

To try the candidate directly:

git clone --branch v1.0.0-rc.1 https://github.com/RickBarretto/html.pkgr.art.git
cd html.pkgr.art
arturo --no-color exp.art
arturo -p install html

Then use import {html}! in your script. Arturo can also install it on first import.

Trying this branch? Clone the repo and use import {src/html}! from its root,
as shown here. Registry installs use published releases and may have an older API.

Quick Start

Save the example above as page.art in the repository root, then run:

arturo page.art > page.html

Open page.html in your browser. That's it.

Just need a fragment?

Use fragment to group elements without adding a wrapper:

print fragment [
  h2 "Hello <world>"
  p "This text is escaped."
]
; <h2>Hello &lt;world&gt;</h2><p>This text is escaped.</p>

Build a component

Return a fragment from a function. Nest it like any tag:

greeting: function [name][fragment [p name]]

print fragment [
  section [
    greeting "Ana"
    greeting "João"
  ]
]

Add attributes

Use .name: value. Underscores become hyphens:

print fragment [
  a.href: "https://arturo-lang.io" "Visit Arturo"
  input #[name: "email" required: true]
  p.data_state: "ready" "All set!"
]

Need custom tags, loops, or trusted HTML? Head to the API reference.

Try the Examples

Blog, landing page, chat UI, Tailwind, daisyUI, and Bootstrap — pick an example.

arturo --no-color preview.art

Open http://localhost:18966/. First run installs Lanx 0.2.0 and its missing
dependencies. Stop with Ctrl+C; rerun after edits. Framework examples need
internet access for styling; chat replies are local demos.

To generate the gallery without starting the server or installing Lanx:

arturo --no-color preview.art build

A Few Rules

  • Every tag takes one content argument. For an empty tag, use [] or #[].
  • Tags return markup objects. Print them, or use to :string when you need a string.
  • Inside child blocks, tag names such as div and input take over built-ins.
    See name collisions.
  • raw skips escaping. Use it only for trusted content, including script and style bodies.
    URLs, JavaScript, and CSS are not sanitized.
  • This is an HTML5 serializer. HTML4, SVG/MathML, and content-model validation aren't supported.

Development

Install Unitt 3.1.1 and make sure its
executable is on PATH ($HOME/.arturo/packages/bin on Unix):

arturo -p install unitt 3.1.1
arturo --no-color test.art            # all suites, including example output
arturo --no-color test.art element    # one suite
arturo --no-color exp.art             # small demo

The test entry point uses config.art and preserves failure status for Unitt's
uncaught-error path on Arturo 0.10.0.

License

MIT.

  -
  
  6
Author
RickBarretto
Version
License
MIT

Executable?
No
Requires
Arturo >= 0.10.0