Created
June 12, 2015 23:17
-
-
Save pelonpelon/45844f7da25e9c2b519a to your computer and use it in GitHub Desktop.
Mithril experiment mithriljs: Mithril template // source http://jsbin.com/mawuzi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Mithril experiment</title> | |
<meta name="description" content="mithriljs: Mithril template"> | |
<meta charset="utf-8"> | |
<script> | |
window.log = function(){ | |
log.history = log.history || []; // store logs to an array for reference | |
log.history.push(arguments); | |
if(this.console){ | |
console.log( Array.prototype.slice.call(arguments) ); | |
} | |
}; | |
$ = function(sel, ctx){return (ctx || document).querySelector(sel)} | |
$$ = function(sel, ctx){return (ctx || document).querySelectorAll(sel)} | |
</script> | |
<script src="https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js"></script> | |
<!-- <script src="http://cdnjs.cloudflare.com/ajax/libs/mithril/0.2.0/mithril.min.js"></script> --> | |
<!-- modified Mithril with redraw console.logs (extensive) --> | |
<!-- <script src="http://output.jsbin.com/gaciwi.js"></script> --> | |
<!-- modified Mithril with redraw console.logs (redraws only) --> | |
<script src="http://output.jsbin.com/gaciwi/24.js"></script> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
App = {} | |
getFile = function(){ | |
console.log('errored?'); | |
return m.request({ | |
method: "GET", | |
url: "http://jsbin.com/mawuzi/1/edit?js,console,output#export-gist" | |
}) | |
} | |
myComp = { | |
controller: function(){ | |
log("controller") | |
this.p = getFile() | |
//getFile().then(function(f){ | |
// console.log(f) | |
// }) | |
}, | |
view: function(ctrl){ | |
log("view") | |
return m("div", ctrl.p()) | |
} | |
} | |
App.view = function(){ | |
return [ | |
myComp | |
] | |
} | |
m.mount(document.body, App) | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<title>Mithril experiment</title> | |
<meta name="description" content="mithriljs: Mithril template"> | |
<meta charset="utf-8"> | |
<script> | |
window.log = function(){ | |
log.history = log.history || []; // store logs to an array for reference | |
log.history.push(arguments); | |
if(this.console){ | |
console.log( Array.prototype.slice.call(arguments) ); | |
} | |
}; | |
$ = function(sel, ctx){return (ctx || document).querySelector(sel)} | |
$$ = function(sel, ctx){return (ctx || document).querySelectorAll(sel)} | |
<\/script> | |
<script src="https://rawgit.com/lodash/lodash/3.0.1/lodash.min.js"><\/script> | |
<\!-- <script src="//cdnjs.cloudflare.com/ajax/libs/mithril/0.2.0/mithril.min.js"><\/script> --> | |
<\!-- modified Mithril with redraw console.logs (extensive) --> | |
<\!-- <script src="http://output.jsbin.com/gaciwi.js"><\/script> --> | |
<\!-- modified Mithril with redraw console.logs (redraws only) --> | |
<script src="http://output.jsbin.com/gaciwi/24.js"><\/script> | |
</head> | |
<body> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
App = {} | |
getFile = function(){ | |
console.log('errored?'); | |
return m.request({ | |
method: "GET", | |
url: "http://jsbin.com/mawuzi/1/edit?js,console,output#export-gist" | |
}) | |
} | |
myComp = { | |
controller: function(){ | |
log("controller") | |
this.p = getFile() | |
//getFile().then(function(f){ | |
// console.log(f) | |
// }) | |
}, | |
view: function(ctrl){ | |
log("view") | |
return m("div", ctrl.p()) | |
} | |
} | |
App.view = function(){ | |
return [ | |
myComp | |
] | |
} | |
m.mount(document.body, App)</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = {} | |
getFile = function(){ | |
console.log('errored?'); | |
return m.request({ | |
method: "GET", | |
url: "http://jsbin.com/mawuzi/1/edit?js,console,output#export-gist" | |
}) | |
} | |
myComp = { | |
controller: function(){ | |
log("controller") | |
this.p = getFile() | |
//getFile().then(function(f){ | |
// console.log(f) | |
// }) | |
}, | |
view: function(ctrl){ | |
log("view") | |
return m("div", ctrl.p()) | |
} | |
} | |
App.view = function(){ | |
return [ | |
myComp | |
] | |
} | |
m.mount(document.body, App) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment