(define-macro (mithril:init) "(mithril:init) Loads Mithril into the document head and sets the pragma->sxml function." `(begin (get-resource "https://cdnjs.cloudflare.com/ajax/libs/mithril/2.2.2/mithril.min.js") (pragma->sxml m))) (mithril:init) (define-macro (mithril:comp view . args) "(mithril:comp view . args) Creates a Mithril component object, where VIEW is a function body used to display the component, and ARGS is a list of keyword-value pairs that specify additional values on the component object. For example, the following code creates a stateful heading component: ``` (define Heading (component (sxml (h1 ~vnode.state.title)) :title \"Title Text\")) ```" (when (and (not (null? args)) (= (remainder (length args) 2 1))) (error (format "mithril:comp-> Component macro expects even length args list. Call: (mithril:comp ~s ~s)" view args))) `(object :view (lambda (vnode) (,@view)) ,@args))