🔗Overview
The system module is auto-loaded in every compile, no import needed. It covers operators, conversion, introspection, JSON, OS access, and two internal CSS helpers.
🔗Operators
Bool/number operations: + - * / == != < <= > >=, not, and or && ||, is isnot, mutating += -= *= /=, and inc / dec.
var i = 0
$i = $i + 1
.a { z-index: $i; }🔗String concatenation with &
The & operator concatenates strings with strings, ints, floats, bools, and JSON values.
var label = "p-" & 1 /* "p-1" */🔗range
range(lo: int, hi: int) is iterable for for loops. Constant bounds inline to bytecode and are never invoked at runtime. The range is inclusive.
for i in range(1, 3):
.p-${$i}
z-index: $i
/* -> .p-1{z-index:1}.p-2{z-index:2}.p-3{z-index:3} */🔗type
Returns the runtime type name of a value: "bool int float string json array object".
var t = type(42) /* "int" */🔗jsonType
Returns the JSON type name of a JSON value.
var t = jsonType(parseJSON("{\"a\": 1}"))🔗toInt
Converts a float to int.
var i = toInt(1.9) /* 1 */🔗parseInt
Parses a string into an int.
var i = parseInt("42")🔗toFloat
Converts an int to float.
var f = toFloat(2) /* 2.0 */🔗toString
Converts ints, floats, bools, JSON, objects, colors, lengths, and other typed values to strings.
var s = toString(42) /* "42" */🔗echo
Prints a value during compilation for debugging. Overloaded for strings, ints, floats, bools, JSON, objects, arrays, and typed values. echo inside a stylesheet emits nothing to CSS.
var x = 10
echo($x)🔗assert
Asserts a condition at compile time.
assert($x > 0)🔗len
Returns the length of a string, JSON value, or array.
var n = len("hello") /* 5 */🔗high
Returns the last index of a JSON value or array.
var h = high($arr)🔗hasKey
Tests whether a JSON value or object has a key.
var ok = hasKey($data, "name")🔗shuffle
Returns a randomized copy of an array.
var s = shuffle($items)🔗parseJSON
Parses a string into a JSON value.
var data = parseJSON("{\"a\": 1}")🔗loadJSON
Loads a JSON value from a file path.
var data = loadJSON("./tokens.json")🔗remoteJSON
Fetches JSON from a URL, returning {status, headers, content}. Never throws; errors land in content.error.
var res = remoteJSON("https://example.com/tokens.json")🔗readFile
Reads a file from disk into a string.
var text = readFile("./notes.txt")🔗writeFile
Writes content to a file on disk.
writeFile("./out.txt", $text)🔗sleep
Pauses compilation for the given milliseconds.
sleep(100)🔗cssStr
Renders one value to its CSS display text. This is a parser-desugared internal helper; avoid direct use.
var s = cssStr($colorVar)🔗cssJoin
Joins pre-stringified parts with literal separators. Used for dynamic multi-values such as margin: $a $b. This is a parser-desugared internal helper; avoid direct use.
.a { margin: $top $right; }