31 lines
768 B
Scheme
31 lines
768 B
Scheme
(define (mithril:init)
|
|
"(mithril:init)
|
|
|
|
Loads Mithril into the document head and sets the
|
|
pragma->sxml function."
|
|
(get-resource )
|
|
(pragma->sxml m))
|
|
|
|
(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 (= (remainder (length args) 2 1))
|
|
(error "Component macro expects even length args list."))
|
|
`(object
|
|
:view
|
|
(lambda (vnode) (,@view))
|
|
,@args))
|