Orca · API

orca.html

Writing HTML: every value escaped, markup only where it's said to be.

var h = Html()
h.raw("<td>")
h.text(step.error)        # `<script>` comes out as text
h.raw("</td>")
h.link("/runs/7", "run 7")

orca ui writes its pages through this rather than a template engine: a page is tables of records, and writing it in Mojo keeps each value's type until the moment it's escaped.

Structs

Html

struct Html

A page being written.

Implements Movable, Writable

Fields
out: String

__init__

def __init__(out self)

raw

def raw[*Ts: Writable](mut self, *parts: *Ts.values)

Markup, written as it is. Only ever literals of this module's callers, never a value from the database or a request.

text

def text[*Ts: Writable](mut self, *values: *Ts.values)

Values, each written and then escaped.

cell

def cell[*Ts: Writable](mut self, *values: *Ts.values)

One <td> holding the values, escaped.

status

def status(mut self, s: StringSpan)

A status as a badge, its class named after it.

finish

def finish(deinit self) -> String

The page written.

write_to

def write_to(self, mut writer: T)

Functions

escape

def escape(s: StringSpan) -> String

s with &, <, >, " and ' as character references, safe in text and in a quoted attribute.

url_encode

def url_encode(s: StringSpan) -> String

s as one path segment or query value: unreserved bytes as they are, every other byte as %XX.

url_decode

def url_decode(s: StringSpan) -> String

%XX and + in a query value decoded; a malformed escape is kept as it is.