Inbox
Welcome back, Grace. 3 new
Syntax
A .rocx file is Roc with markup (HTML elements and components) wherever an expression can stand; inside markup, braces take you back to Roc. rocx turns markup into calls to the platform's Html module, so every .rocx file has import pf.Html. Each example is a real file in site/examples, shown with its output; its switch shows the Roc rocx wrote.
Signals, a memo, handlers, holes, keyed rows, an if and a scoped style, each explained below. Type a title and press Enter, or tick a book off.
2 to read
import pf.Html
import pf.Solid exposing [create_memo!, create_signal!]
## A reading list: type a title and press Enter, tick a book off.
SyntaxTour := [].{
view! : {} => Html
view! = |{}| {
book = |id, title| { id, title, done: Bool.False }
(books!, set_books!) = create_signal!([book(1, "Dune"), book(2, "Emma")])
(draft!, set_draft!) = create_signal!("")
left! = create_memo!(|| books!().count_if(|b| !b.done))
add! = || {
if !draft!().is_empty() {
set_books!(books!().append(book(books!().len() + 1, draft!())))
set_draft!("")
}
}
tick! = |id|
set_books!(books!().map(|b| if (b.id == id) { ..b, done: !b.done } else b))
<section class="tour">
<input
placeholder="Add a book"
value={draft!()}
on:input.value={set_draft!}
on:keydown.Enter={add!}
/>
<ul>
{...books!().map(|b|
<li key={b.id} class:done={b.done}>
<input type="checkbox" checked?={b.done} on:change={|| tick!(b.id)} />
{b.title}
</li>
)}
</ul>
{if (left!() == 0) <p>All read.</p> else <p>{left!()} to read</p>}
</section>
}
<style>
.done {
text-decoration: line-through;
}
</style>
}This table is a component too: type to filter it.
| Write | Means |
|---|---|
<tag attr="text" other={expr}>…</tag> | An element; {expr} must be a Str, and is escaped. |
{expr} | Text (escaped), a number or markup, as the expression's type says. In a component, it runs again when a signal it read changes, and patches its node. |
{...expr} | A List(Html), joined: what .map makes. |
checked?={bool} | A boolean attribute, there when true. |
required | A boolean attribute that is always on. |
rel??={str} | An attribute left out when the string is empty. |
class:active={bool} | Adds a class when true; all classes end up in one class attribute. |
style:--size={str} | Sets a CSS custom property; unsafe values are left out. |
style:color={str} | Sets one property of the style, checked the same way; computed if it reads a signal. |
on:click={|| …} | In a component: runs the handler, an effect, when the event happens. |
on:input.value={set_draft!} | Gives the handler the target's value (a Str). |
on:change.checked={|done| …} | Gives the handler whether the target is checked (a Bool). |
on:keydown.key={|key| …} | Gives the handler the key's name (Enter, Escape…). |
on:keydown.ArrowUp={|| …} | Runs for that key only, with no modifier key held, and keeps the key from scrolling the page. .Space is the space bar. |
on:keydown.Mod+K={|| …} | Runs for that key with exactly those modifier keys held: Shift, Ctrl, Alt, Meta, and Mod (⌘ on macOS, Ctrl elsewhere). |
<Document on:keydown.Escape={|| …} /> | Handlers on the whole document while it is there; it renders nothing. <Window on:resize={…} /> is the window's. |
on:keydown.keys={|keys| …} | Gives the handler the key and the modifier keys held: keys.key, keys.shift, keys.mod… |
on:frame.ms={|ms| …} | Runs every animation frame, given the milliseconds since the last, while the element is on the page. |
transition={Transition.fade} | Plays as the element's row or part comes and goes; transition:in and transition:out play one way. A row that goes stays until it has. |
(count!, set_count!) = create_signal!(0) | A signal: an accessor, which whatever reads it subscribes to, and a setter. |
total! = create_memo!(|| …) | A value computed from signals once per change, for everything that reads it. |
{if ready!() { … } else { … }} | The branch that holds, kept while it does; made anew when another one does. |
{match card!() { Ok(card) => …, Err(_) => … }} | The arm that holds, kept while it does; its names read the newest value. |
{...rows!().map(|row| <li key={row.id}>…</li>)} | A row per key, kept and moved as the list changes; .map_with_index(|row, i| <li key={i}>…) keeps rows by position. |
<Loading fallback={…}> | What shows while an answer from the server is on its way. |
<Errored fallback={|problem, retry| …}> | What shows when something inside failed, and a way to try again. |
get! = |{ params, context, .. }| Ok(…) | In a route's +server.roc: its GET endpoint, given its path's params and what its middleware handed on. |
Api.get_profile({ id }).read!() | A GET endpoint's answer as a plain value: the server answers it as it renders the page, which carries it to the browser. |
<StatusPill status={s} /> | A component: StatusPill.view!({ status: || s }), run once, where it is rendered; its props are getters, read where it reads them. |
<Card>children</Card> | Children become a children : List(Html) prop. |
<>…</> | A fragment: its children side by side, no element around them. <></> is nothing. |
<!doctype html> | The doctype. |
{# a comment } | A comment that never reaches the page. |
<!-- a comment --> | Also a comment that never reaches the page. |
<script>…</script> | Script or style text, kept as written; never with values in it. |
<style>…</style> beside a component's definitions | CSS for that component's markup only, scoped as Svelte scopes it. |
& · — | Entities: the character. |
37 of 37
Elements are written as in HTML, tag names in lower case. Empty elements close themselves (<br />, <img />, <input />); a bare <br> is refused. Text is escaped: a < in a name shows as itself, never as a tag.
Markup is an ordinary Roc expression: name it, return it, put it in a list. A fragment, <>…</>, holds elements side by side, so nothing needs a single root; <></> is nothing at all. The Roc rocx writes keeps your line numbers, so compiler reports point at your lines.
view : { name : Str, link : Str } -> Html
view = |{ name, link }|
<p class="greeting">
Hello, <a href={link} title="Their profile">{name}</a>!
</p>view : { name : Str, link : Str } -> Html
view = |{ name, link }|
Html.element("p", [Html.attr_literal("class", "greeting"),], [
Html.text("Hello, "), Html.element("a", [Html.attr("href", link), Html.attr_literal("title", "Their profile"),], [Html.shown(name),]), Html.text("!"),
])<p class="greeting">Hello, <a href="/people/ada?tab=notes&sort=new" title="Their profile">Ada <Lovelace></a>!</p>Live
Hello, Ada <Lovelace>!
A hole, {x}, puts a Roc expression in markup, shown by its type: a Str as escaped text, a number as digits, Html as markup. Any other type, such as a Bool or a record, is a compile error at your line. A list hole, {...xs}, shows a List(Html)'s items in order.
<p>{name} has {count} messages, {"${unread.to_str()} unread"}.</p>
<ul>{...tags.map(|tag| <li>{tag}</li>)}</ul>In a component, a hole reruns and patches its own node when what it reads changes: a call of a name ending in ! (a signal such as count!(), a memo, an accessor prop) or an effectful component's prop. Any other hole is worked out once.
An attribute's value is a quoted string or a Roc expression in braces. Other forms cover what HTML makes awkward:
| Written | Means |
|---|---|
name="text", name='text' | A static value, as written, entities decoded, on one line. |
name={expr} | A Str from Roc, escaped. In a component, set again when what it reads changes. |
name | A boolean attribute that is always on, such as required. |
name?={bool} | A boolean attribute, there while the Bool is true: disabled?={busy}. |
name??={str} | Left out while the string is empty. |
class:name={bool} | Adds the class while the Bool is true. All the element's classes, a computed class={…}'s too, end up in one class attribute. |
style:--name={str} | Sets a CSS custom property, for the stylesheet to use. |
style:color={str} | Sets one CSS property. Its name is letters and dashes. |
style="…" | A static style, which the style: attributes join. |
<img enhanced:src={path} /> | A photo of this site (a quoted path too) that the server makes smaller copies of. Once they are made, a moment after a page first shows it, pages get their srcset, a sizes and the photo's width and height; until then, its src. It loads lazily and decodes off the main thread unless loading, fetchpriority or decoding says otherwise. Only an <img> takes it, and never beside a src or srcset. See the server. |
view : { email : Str, required : Bool, rel : Str, active : Bool, size : Str } -> Html
view = |{ email, required, rel, active, size }|
<div class="signup">
<input type="email" name="email" value={email} required?={required} autofocus />
<a href="/terms" rel??={rel}>Terms</a>
<button type="button" class="primary" class:active={active} style:--size={size}>Join</button>
</div>view : { email : Str, required : Bool, rel : Str, active : Bool, size : Str } -> Html
view = |{ email, required, rel, active, size }|
Html.element("div", [Html.attr_literal("class", "signup"),], [
Html.void("input", [Html.attr_literal("type", "email"), Html.attr_literal("name", "email"), Html.attr("value", email), Html.flag("required", required), Html.flag("autofocus", Bool.True),]), Html.text(" "),
Html.element("a", [Html.attr_literal("href", "/terms"), Html.optional("rel", rel),], [Html.text("Terms"),]), Html.text(" "),
Html.element("button", [Html.attr_literal("type", "button"), Html.attr_literal("class", "primary"), Html.class_if("active", active), Html.style_var("--size", size),], [Html.text("Join"),]),
])<div class="signup"><input type="email" name="email" value="ada@example.com" required autofocus> <a href="/terms">Terms</a> <button class="primary active" type="button" style="--size: 1.25rem">Join</button></div>Live
rocx refuses an unquoted value (class=big), a whole computed style (style={…}) and an inline handler (onclick="…"; in a component, write on:click={…}). A style: value is dropped if it holds anything but letters, digits, spaces and .,%#()-+, or calls a CSS function that could load something (rgb(), calc(), var() and other computing functions are fine; url() is not). URL attributes (href, src, action and a few more) take only safe URLs.
Branches and lists need no special syntax: if, match and .map work in a hole as anywhere in Roc. An if in a hole needs no else: {if (late) <p>Late</p>} shows nothing (<></>) while late is false. This example's list is a plain value, rendered once:
Post : { title : Str, status : [Draft, Published(Str)] }
view : List(Post) -> Html
view = |posts|
<section>
<h3>{if (posts.is_empty()) "No posts yet" else "${posts.len().to_str()} posts"}</h3>
<ul>
{...posts.map(|post|
<li>
{post.title}
{match post.status {
Draft => <em>draft</em>
Published(day) => <time>{day}</time>
}}
</li>
)}
</ul>
</section>Post : { title : Str, status : [Draft, Published(Str)] }
view : List(Post) -> Html
view = |posts|
Html.element("section", [], [
Html.element("h3", [], [Html.shown(if (posts.is_empty()) "No posts yet" else "${posts.len().to_str()} posts"),]), Html.text(" "),
Html.element("ul", [], [
Html.join(posts.map(|post|
Html.element("li", [], [
Html.shown(post.title), Html.text(" "),
Html.shown(match post.status {
Draft => Html.element("em", [], [Html.text("draft"),])
Published(day) => Html.element("time", [], [Html.shown(day),])
}),
])
)),
]),
])<section><h3>2 posts</h3> <ul><li>Hello, rocx <time>Nov 19</time></li><li>Islands <em>draft</em></li></ul></section>Live
In a component, where values change, they keep the markup they made:
if or match on something changing keeps its branch's markup, and the signals of components inside, while that branch holds; it makes another branch's markup only when that one holds. A match arm's names always read the newest value..map over a changing list makes rows kept by key, given on each row's outermost element or component: {...todos!().map(|todo| <li key={todo.id}>{todo.title}</li>)}. A row is made once per key, moved on a reorder and dropped when its key goes, so focus and typing inside survive. It updates only when its item is no longer == the old one. A row that is an if keys each branch..map_with_index(|item, i| <li key={i}>…</li>) makes a row per position instead: rows stay put, each showing the item now at its position.key={i} alone).if, match and .map, on the components page, shows each live.
A capitalised tag is a component: a function from a record of props to Html. <StatusPill status={s} /> calls StatusPill.view (or view!) when the file imports or defines a StatusPill module, and this file's status_pill otherwise. Each attribute is a prop: a string, a Roc value in braces, or a bare name (Bool.True). What is between the tags is the children prop, a List(Html). A missing prop is a type error, unless the props are a nominal record with defaults (title : Str ?? "").
view : { name : Str, unread : U64 } -> Html
view = |{ name, unread }|
<Card title="Inbox">
<p>Welcome back, {name}. <Badge count={unread} /></p>
</Card>
card : { title : Str, children : List(Html) } -> Html
card = |{ title, children }|
<article class="card">
<h4>{title}</h4>
{...children}
</article>
badge : { count : U64 } -> Html
badge = |{ count }| <span class="badge" class:zero={count == 0}>{count.to_str()} new</span>view : { name : Str, unread : U64 } -> Html
view = |{ name, unread }|
card({ title: "Inbox", children: [
Html.element("p", [], [Html.text("Welcome back, "), Html.shown(name), Html.text(". "), badge({ count: unread, }),]),
], })
card : { title : Str, children : List(Html) } -> Html
card = |{ title, children }|
Html.element("article", [Html.attr_literal("class", "card"),], [
Html.element("h4", [], [Html.shown(title),]), Html.text(" "),
Html.join(children),
])
badge : { count : U64 } -> Html
badge = |{ count }| Html.element("span", [Html.attr_literal("class", "badge"), Html.class_if("zero", count == 0),], [Html.shown(count.to_str()), Html.text(" new"),])<article class="card"><h4>Inbox</h4> <p>Welcome back, Grace. <span class="badge">3 new</span></p></article>Live
Welcome back, Grace. 3 new
There are two kinds of component (pure and effectful):
view with no !, is a plain function, called where it is written. Its props are values; it makes no signals.view!, runs once, where it is rendered, and may make signals. Its value props are getters: rocx passes each as a function, so reading the prop gets the current value, and a parent can pass something that changes.| Written | Means |
|---|---|
<Field value!={draft!} /> | A prop named with ! is an accessor, called like a signal: value!() (props that change). |
<Card {...rest} /> | Passes a record of props on as is, such as the rest of a view's props (|{ title, ..rest }|). |
<Repeat count!={n!()}>{|index| …}</Repeat> | A function as the only child is passed as children to the component's view_with!, which calls it. |
<ThemeContext value={dark}>…</ThemeContext> | Provides a context, defined with create_context, to the markup inside (contexts). |
<Card key={card.id} … /> | On a component that is a list row's outermost tag, key is the row's key, never a prop. |
A handler, on:event={…}, is a Roc function the browser runs when the event reaches the element. It may set signals, call the server and so on; the server renders nothing for it. A suffix on the event's name says what the handler is given, or when it runs:
| Written | Means |
|---|---|
on:click={|| …} | Runs on the event. on:submit also stops the browser's own submit. |
on:input.value={set_draft!} | Given the element's value, a Str. |
on:change.checked={|on| …} | Given whether it is checked, a Bool. |
on:keydown.key={|key| …} | Given the key's name (Enter, k). .keys gives the key and the modifier keys held (keys.shift, keys.mod…). |
on:keydown.Escape={|| …} | Runs for that key alone, with no modifier held, and stops the browser's default (an arrow key scrolling the page). .Space is the space bar; letters and digits work too (.w). |
on:keydown.Mod+K={|| …} | Runs for that key with exactly those modifier keys held: Shift, Ctrl, Alt, Meta, and Mod, which is ⌘ on macOS and Ctrl elsewhere. |
on:click.prevent={|| …} | Stops the browser's default first, such as following a link the page takes over. |
on:pointermove.point={|p| …} | Given where the pointer is over the element, as shares of its width and height. |
on:drop.data={|items| …}, .files | Given what a drop or a paste carries, or its files; on:change.files on a file input gives the files chosen. |
on:frame.ms={|ms| …} | Runs every animation frame while the element is on the page, given the milliseconds since the last. |
on:viewport={|view| …} | Runs when the element shows, and each time it scrolls or changes size, given what of it shows. |
on:visibilitychange.visible={|shown| …} | On <Document>: given whether the page shows (false while its tab is hidden). |
view! : {} => Html
view! = |{}| {
(draft!, set_draft!) = create_signal!("Hello")
(agreed!, set_agreed!) = create_signal!(Bool.False)
(saved!, set_saved!) = create_signal!("")
<form on:submit={|| set_saved!(draft!())}>
<input value={draft!()} on:input.value={set_draft!} on:keydown.Escape={|| set_draft!("")} />
<input type="checkbox" checked?={agreed!()} on:change.checked={set_agreed!} />
<button disabled?={!agreed!()}>Save</button>
<output>{saved!()}</output>
</form>
}view! : {} => Html
view! = |{}| {
(draft!, set_draft!) = create_signal!("Hello")
(agreed!, set_agreed!) = create_signal!(Bool.False)
(saved!, set_saved!) = create_signal!("")
Html.element("form", [Html.on("submit", || set_saved!(draft!())),], [
Html.void("input", [Html.attr_of("value", || draft!()), Html.on_value("input", set_draft!), Html.on_named_key("keydown", "Escape", || set_draft!("")),]), Html.text(" "),
Html.void("input", [Html.attr_literal("type", "checkbox"), Html.flag_of("checked", || agreed!()), Html.on_checked("change", set_agreed!),]), Html.text(" "),
Html.element("button", [Html.flag_of("disabled", || !agreed!()),], [Html.text("Save"),]), Html.text(" "),
Html.element("output", [], [Html.hole_of(|| Html.hole(saved!())),]),
])
}Other attributes that only mean something in the browser:
key={…} names an element: on a list row, its key; anywhere, it keeps an element moved between lists the same element, so it can glide between them.transition={…}, transition:in={…} and transition:out={…} play an animation (a Transition, such as Transition.fade) as the element's row or branch comes and goes; transition:move={…} glides it when it moves (transitions).drag:data={[(type, value)]} is what a drag of the element carries, and drag:image={id} the element shown while it is dragged (drag and drop).Markup inside a <NoHydration> never runs in the browser, so rocx refuses a handler, key, transition or drag: attribute there, at its line. The components page covers signals and handlers in depth.
A few capitalised tags are rocx's own, unless your file has a module of the same name:
| Written | Means |
|---|---|
<NoHydration>…</NoHydration> | Markup only the server renders. The browser keeps its HTML as is; none of the code inside is in the wasm. |
<Document on:keydown.Mod+K={…} />, <Window on:resize={…} /> | Handlers on the whole document or window, while the markup around the tag is rendered. They take only handlers and render nothing. |
<Meta name="description" content={…} />, <Link … />, <Style>…</Style> | A <meta>, <link> or <style> in the document's <head>, while the markup around the tag is rendered. |
<!doctype html> | The doctype, at the top of a root layout. |
<story name="…">…</story> | One way a component looks, for the dev build's catalog (stories). |
The platform also has components you import (import pf.Loading, and so on): <Loading fallback={…}> and <Errored fallback={…}> for waiting and failing, <Repeat> for rows without a list, <Title> for the document's title, <HttpStatusCode code={404} /> for the status the server answers the page with, and <Navigate> for navigating.
Text follows HTML's rule, as in Svelte (not JSX): each run of spaces, tabs and line breaks is one space. Whitespace with a line break next to an element's own opening or closing tag is dropped; a space on the tag's line stays (<b>On the tag's line: </b>). So prose can break lines anywhere, even next to a link or a value, and elements on lines of their own get a space between them. <pre> and <textarea> keep text as written.
view : { name : Str } -> Html
view = |{ name }|
<div>
<p>
Prose breaks lines anywhere: next to a
<a href="/links">link</a> or a value like
{name}, and each break is one space.
</p>
<p><b>On the tag's line: </b>a space stays.</p>
<pre>kept as
written</pre>
</div> view : { name : Str } -> Html
view = |{ name }|
Html.element("div", [], [
Html.element("p", [], [
Html.text("Prose breaks lines anywhere: next to a "),
Html.element("a", [Html.attr_literal("href", "/links"),], [Html.text("link"),]), Html.text(" or a value like "),
Html.shown(name), Html.text(", and each break is one space."),
]), Html.text(" "),
Html.element("p", [], [Html.element("b", [], [Html.text("On the tag's line: "),]), Html.text("a space stays."),]), Html.text(" "),
Html.element("pre", [], [Html.text("kept as\n written"),
]),
])<div><p>Prose breaks lines anywhere: next to a <a href="/links">link</a> or a value like Grace, and each break is one space.</p> <p><b>On the tag's line: </b>a space stays.</p> <pre>kept as
written</pre></div>Live
Prose breaks lines anywhere: next to a link or a value like Grace, and each break is one space.
On the tag's line: a space stays.
kept as written
{# … } and <!-- … --> are comments; they never reach the page. A {# … } comment ends at the first }, so it can't contain one. Entities work: the common named ones (&, ·, …) and numeric ones (→); rocx refuses one it doesn't know. Write a literal <, >, { or } in text as an entity or a string in a hole ({"{"}), so a stray brace is never silently text.
A <script> or <style> in markup keeps its text as written, braces included, and takes no holes: a page's script is part of the page, never data. A <style> beside a component's definitions, outside its markup, is scoped to that component.
view : {} -> Html
view = |{}|
<>
{# For whoever reads this file: it never reaches the page. }
<style>.raw-demo b { letter-spacing: 0.05em }</style>
<p class="raw-demo">
<b>Tom & Jerry</b> · 1–2 → {"{braces}"} and <tags>
</p>
<!-- Nor does this. -->
</>view : {} -> Html
view = |{}|
Html.join([
Html.element("style", [], [Html.source_text(".raw-demo b { letter-spacing: 0.05em }"),]), Html.text(" "),
Html.element("p", [Html.attr_literal("class", "raw-demo"),], [
Html.element("b", [], [Html.text("Tom & Jerry"),]), Html.text(" · 1–2 → "), Html.shown("{braces}"), Html.text(" and <tags>"),
]),
])<style>.raw-demo b { letter-spacing: 0.05em }</style> <p class="raw-demo"><b>Tom & Jerry</b> · 1–2 → {braces} and <tags></p>Live
Tom & Jerry · 1–2 → {braces} and <tags>
A <style> in a component's block, beside its definitions, styles only that component's markup, as in Svelte. rocx adds a class named after the component to each element written in the block and to each selector: .card .title becomes .card.rx-… .title:where(.rx-…), one class more specific than written, however long the selector. So two components' .card rules never meet, even in one file; a bare p is only this component's paragraphs; and styles don't reach into the components it renders. A page or layout has no block, so its <style> goes at the file's top level, for the whole file. A component, or a file's top level, has at most one <style>, with no attributes, and no @import, @charset or @namespace (they must come first in a stylesheet). Its lines are blank in the Roc, so line numbers stay yours.
view : { title : Str, note : Str } -> Html
view = |{ title, note }|
<figure class="card">
<p class="title">{title}</p>
<p>{note}</p>
</figure>
<style>
.card {
margin: 0;
padding: 0.75rem 1rem;
border-left: 3px solid var(--accent);
}
.card .title {
font-weight: 700;
}
p {
margin: 0.25rem 0 0;
font-style: italic;
}
</style>view : { title : Str, note : Str } -> Html
view = |{ title, note }|
Html.element("figure", [Html.attr_literal("class", "card rx-xjqvlj"),], [
Html.element("p", [Html.attr_literal("class", "title rx-xjqvlj"),], [Html.shown(title),]), Html.text(" "),
Html.element("p", [Html.attr_literal("class", "rx-xjqvlj"),], [Html.shown(note),]),
])
<figure class="card rx-xjqvlj"><p class="title rx-xjqvlj">Scoped</p> <p class="rx-xjqvlj">This p is styled; the page's other paragraphs aren't.</p></figure>Live
Scoped
This p is styled; the page's other paragraphs aren't.
Reach outside the component as in Svelte: :global(body), div :global(strong) for any strong inside this component's divs, and a :global { … } block for rules that are all global. A component's @keyframes spin, and spin in its animation, are its own; @keyframes -global-spin is everyone's spin. Nested rules work, & too.
rocx puts every <style> in the app into one stylesheet, Generated/Styles.roc. The root layout adds it to its <head> with <NoHydration>{Styles.style}</NoHydration> (so none of it is in the wasm): a <link> to /rocx/styles-hash.css, named by its content, so the browser keeps it for every page and any change gives it a new name.
A <story name="…"> in a component's block holds the markup of one way the component looks; its name starts with a letter, and the tag takes nothing else. Each story becomes a definition in its place (<story name="Tip"> is story_tip!), so every build checks it against the component, but only a dev build (rocx dev) shows it, in a catalog at /__rocx/stories (stories).
< starts markup only where an expression can begin, and only when a letter, > or ! follows. After a value on the same line it is a comparison.
| Written | Read as |
|---|---|
x = <b>hi</b>, f(<b/>), [<i/>, <b/>], Html ?? <></> | markup: after =, (, [, ,, ?? |
|post| <li>…</li>, A => <b/> | markup: a lambda's body, a branch |
if (a < b) <b/> else <i/> | a comparison in the condition, then markup after it and after else |
| first on its line | markup: a block's last expression |
a < b, f(x)<y, n<b | a comparison: a value comes before it |
"<b>", '<', # <i> | left alone: strings, characters and comments |
Markup is the platform's Html type everywhere. A pure component, view, is a function such as { … } -> Html; an effectful one, view!, an effect: { … } => Html. A prop's default may be markup: fallback : Html ?? <></>. In plain Roc, these build markup without rocx:
| Function | For |
|---|---|
Html.to_strHtml -> Str | markup with nothing to run in it, as a string: an email's HTML, an expect |
Html.textStr -> Html | escaped text |
Html.joinList(Html) -> Html | several, as one |
Html.empty{} -> Html | nothing at all (<></> in markup) |
Html.doctype{} -> Html | the doctype (<!doctype html> in markup) |
The platform reference lists every function of Html and the other modules.