Basic mithril functions
This commit is contained in:
parent
1c3f8a90a3
commit
5af68c527a
3 changed files with 33 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
*~
|
||||||
31
mithril.scm
Normal file
31
mithril.scm
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
(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))
|
||||||
1
nitinol.scm
Normal file
1
nitinol.scm
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
(include "mithril.scm")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue