Next: , Up: API  


1.1 (hygguile abstraction)

1.1.1 Procedures

Procedure: attr-when condition name value

Return a one-element list holding the SXML attribute pair (name . value) when condition is true, otherwise the empty list.

This helper makes it easy to build optional HTML attributes without sprinkling if expressions through a template. It is designed to be spliced into an attribute list with ,@, so an unfulfilled condition simply omits the attribute.

condition

Any Scheme value; only #f makes the attribute disappear.

name

A symbol representing the attribute name.

value

The attribute value to render when condition is truthy.

`(img (@ ,@(attr-when srcset 'srcset srcset)
            (alt ,alt)))
Procedure: get-short-commit-sha KEY: #:cmd

Retrieve the short Git commit SHA or execute a custom version control command.

cmd

The shell command string to execute, defaulting to the command that fetches the 7-character short commit hash.

(get-short-commit-sha)
Procedure: mk-class xs

Return a sorted, space-separated string of unique class names from xs.

Takes a list of symbols xs, removes any duplicates, converts them to strings, sorts them alphabetically, and returns them as a single, space-separated string. This is useful for creating a canonical CSS class attribute value.

If xs is the empty list, an empty string is returned.

xs

A list of symbols.

(mk-class '(p-2 bg-stone-900/75))
Procedure: mk-style pairs

Convert an association list of properties and values into a CSS inline style string.

pairs

An association list or list of pairs where each element’s car is the CSS property name and its cdr is the value.

(mk-style '((background-color . "red") (color . "blue")))
Procedure: override-classes base overrides

Return base with every colour utility that overrides also sets removed, then overrides appended.

Utility-class frameworks settle a conflict between two classes that set the same CSS property, such as text-onyx-300 and text-stone-100, by generated-stylesheet order. That order is not the order you wrote, and it is not stable across builds, so the result is a coin flip. The moment two class lists meet – a component’s base classes plus its active-state list, for instance – override-classes makes the outcome deterministic: the later list wins.

Variants count as part of the identity, so dark:text-onyx-900 overrides dark:text-stone-300 without disturbing the light-theme text-onyx-300. Size and shape utilities are never removed.

base

The class list to keep.

overrides

The class list that wins.

(override-classes '(text-onyx-300 dark:text-stone-300)
                  '(text-stone-100 dark:text-onyx-900))
;; => (text-stone-100 dark:text-onyx-900)
Procedure: pretty-quote str

Transform explicit S-expression (quote symbol) fragments within a string into shorthand syntax.

str

The target input string containing raw code snippets or text representations.

(pretty-quote "This is a (quote example) line.")
Procedure: render-if-nempty render-func item

Apply render-func to item if item is neither empty nor false.

Returns an empty list if item evaluates to null or false.

render-func

A single-argument procedure to evaluate the layout with item.

item

The data element or fragment list to inspect.

(render-if-nempty (lambda (i) `(b ,i)) "Bold Text")
Procedure: render-if-nestring expr x

Evaluate and return the result of expr with x if x is a non-empty string.

If x is false or an empty string, returns an empty list.

expr

A single-argument procedure to apply to x.

x

The string value or condition to check.

(render-if-nestring (lambda (val) `((p ,val))) "Hello")
Procedure: syscall cmd

Execute a shell command synchronous process and capture its complete standard output.

cmd

A string designating the system command execution pipeline.

(syscall "uname -a")

Next: (hygguile components button), Up: API