The glyphs

Stoic has no keywords. It has seventeen glyphs, each with one job. Here is every one, with an example the compiler reads back.

Stoic has no vocabulary. Every tag, field, event, handler and capability is a word you choose, passed through verbatim for the reader to interpret, person or agent. What is fixed is a small set of glyphs, and each has exactly one job. Most are borrowed from things you already read: HTML's angle brackets, a shell's &, a pointer's ->.

They fall into four families: structure (what exists), behaviour (what happens), firmness (how strictly it holds) and tests (how we'll know).

Element

<tag … /> or <tag> children </tag> is a thing. A button, a table, a service, a pipeline step, a module's method. Leaving one unclosed at the end of a file is a warning.

Stoic
<gallery>
  <card />
</gallery>
The compiler reads it back

A gallery. It contains a card.

Name

:name names an element, so it can be reused with ->, tested with <test:… =name>, or referred to by a field. Names are unique within a file, and within one lock a name is defined once.

Stoic
<button:like @click="like the post" />
The compiler reads it back

A button like that does "like the post" on click.

Bind

= after a tag binds an element to data or state. On a field, = gives a value, and when that value names another element it is a reference, not a copy.

Stoic
<table:orders=postgres #region="eu-west-1" />
<query:recent=orders @run="orders placed in the last day" />
The compiler reads it back

A table orders bound to postgres. Field region is eu-west-1.

A query recent bound to orders that does "orders placed in the last day" on run.

Reuse

-> makes a copy of another element to adjust, in this file or another (->ui.buttons.primary is primary in ui/buttons.stoic). #-name and @-name leave a field or event out.

Stoic
<service:api #replicas(>=3) @crash="page oncall" />
<service:worker->api @-crash />
The compiler reads it back

A service api that does "page oncall" on crash. Field replicas must be at least 3.

A service worker (like api). Field replicas must be at least 3.

Repeat

* after a tag means one per entry of the parent's data. The parent's actions apply to each one.

Stoic
<list=todos #more([done, delete])>
  <row* @click="open todo" />
</list>
The compiler reads it back

A list bound to todos. Field more provides actions on each row: done and delete. Each row does "open todo" on click.

Field

#name(…) is a property and its rules: limits (>=3), quoted matches ("email"), must-not-contain (!" "), capabilities (sort, filter) and actions ([add, remove]).

Stoic
<form #username(>=3, <=20, !" ") #created(sort, filter) />
The compiler reads it back

A form. Field username must be at least 3 and at most 20 and must not contain spaces. Field created supports sort and filter.

Event

@name="…" is a trigger and what it does, in plain words. @* is every event. The handler is passed to the implementer verbatim, so write it the way you'd say it.

Stoic
<pipeline @push="run checks" @tag="release to production" />
The compiler reads it back

A pipeline that does "run checks" on push and does "release to production" on tag.

Note

A quoted string touching a word, with no space, fine-tunes that word. Notes go wherever detail matters: tags, events, fields, capabilities and actions. With a space it's an error, so you can't attach one by accident.

Stoic
<button"pill shaped" @click"debounce 300ms"="save draft" />
The compiler reads it back

A button ("pill shaped") that does "save draft" on click ("debounce 300ms").

How it runs

Between @ and the event: ~ is an animation (~+ quick, ~- slow) and & runs in the background, like & in a shell. They combine: @&~click.

Stoic
<card @~hover @&open="prefetch the photo" />
The compiler reads it back

A card that has an animation on hover and does "prefetch the photo" in the background on open.

Strict

! touching a name: no exceptions. On an element, it's the default for everything inside it.

Stoic
<form!:payment #amount(>0) #note(<=140) />
The compiler reads it back

A form payment (strict). Field amount must strictly be more than 0. Field note must strictly be at most 140.

Can bend

? touching a name: a preference, not a rule. Tests don't bend: a ? field's examples are still tests.

Stoic
<form #bio?(<=500) #name(>=1) />
The compiler reads it back

A form. Field bio should be at most 500 (can bend). Field name must be at least 1.

Or-value

|value is a value the field takes whatever its limits say: #cycles(>=1, |null) reads "must be at least 1, or null".

Stoic
<job #retries(>=1, <=5, |null) />
The compiler reads it back

A job. Field retries must be at least 1 and at most 5, or null.

Examples

+"…" must be accepted and -"…" rejected. +=1 and -=1.5 are values rather than text. Each example is a test, with an ID like signup_username_rejects_ad. +=>="…" and -=>="…" say what accepting and rejecting reports, as checked values.

Stoic
<form:signup #username(>=3, +"ada", -"ad", +=>="'ok'", -=>="'TOO_SHORT'") />
The compiler reads it back

A form signup. Field username must be at least 3, accepts "ada", and rejects "ad". Each accepted example reports exactly "'ok'"; each rejected one, exactly "'TOO_SHORT'".

Given

^"…" is a step that has already happened before a test's action, as many as it takes, in order. Among a field's arguments, it's how each of the field's examples is tried.

Stoic
<cart:c @add="add an item" />
<test:full=c ^"99 items in the cart" @add =>="'FULL'" />
The compiler reads it back

A cart c that does "add an item" on add.

A test full of c: given 99 items in the cart, on add, expect exactly "'FULL'" (reported back and compared).

Expect

=>"…" is what must happen and =>!"…" what must not. These are guidance for whoever writes the test: verify only sees whether it passed. They're marked (not checked) everywhere they're printed, honestly.

Stoic
<form:f @submit="save" />
<test:saves=f @submit =>"saved" =>!"error shown" =>status="201" />
The compiler reads it back

A form f that does "save" on submit.

A test saves of f: on submit, expect "saved", must not "error shown", and expect status exactly "201" (reported back and compared).

Checked value

=>="…" (or =>label="…" when a test has several) is the glyph that does the enforcing. The test reports the value it observed, and verify compares it with the locked one, as a value: numbers by value, objects in any key order. A test body can be wrong. Its observation can't hide.

Stoic
<method:fee @call="8.75% of amount, rounded half to even" />
<test:fee600=fee @call="600" =>fee="52" />
The compiler reads it back

A method fee that does "8.75% of amount, rounded half to even" on call.

A test fee600 of fee: on call with "600", expect fee exactly "52" (reported back and compared).

Kept comment

<!-- … --> is private and never appears in any output. <!--! … --> is kept: guidance for the implementer, for what a rule can't say. It belongs to the element it's in or right before, or to the whole file when it stands alone.

Stoic
<!--! Left open: whether emails are trimmed. Your choice. -->

<form #email("email") />
The compiler reads it back

A form. Field email must match "email".

Left open: whether emails are trimmed. Your choice.

Your words

Everything else is yours. <gallery>, <chip>, @tap, @clk and #vibe are as valid as <table> and @click. Stoic never checks a name against a vocabulary, because the reader, a person or a model, already knows what a gallery is.

Stoic
<ritual:morning @dawn="make coffee, then read" #duration(<=30) />
The compiler reads it back

A ritual morning that does "make coffee, then read" on dawn. Field duration must be at most 30.

All 18 examples on this page were compiled by Stoic at build time.