35 lines
No EOL
798 B
HTML
35 lines
No EOL
798 B
HTML
<script src="mithril.js"></script>
|
|
<script type="text/javascript">
|
|
//model
|
|
var identity = function(value) {return value}
|
|
var page = function(url) {
|
|
return m.request({method: "GET", url: url, deserialize: identity})
|
|
.then(marked)
|
|
.then(m.trust)
|
|
}
|
|
|
|
//controllers
|
|
var home = function(ctrl) {
|
|
this.title = "Home"
|
|
this.body = m.trust("hello home")//page("home.html")
|
|
}
|
|
var about = function(ctrl) {
|
|
this.title = "Home"
|
|
this.body = m.trust("hello about")//page("about.html")
|
|
}
|
|
|
|
//view
|
|
var layout = function(ctrl) {
|
|
return m("html", [
|
|
m("body", [
|
|
m("h1", ctrl.title),
|
|
m("#app", ctrl.body)
|
|
])
|
|
])
|
|
}
|
|
|
|
m.route(document, "/", {
|
|
"/": {controller: home, view: layout},
|
|
"/about": {controller: about, view: layout}
|
|
})
|
|
</script> |