Last active
September 23, 2015 14:24
-
-
Save Rich-Harris/fa549718d85f3552762c to your computer and use it in GitHub Desktop.
ractive-load demo 1
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
<h1>hello {{name}}!</h1> | |
<style> | |
h1 { color: red; } | |
</style> | |
<script> | |
component.exports = { | |
oninit: function () { | |
get( 'data.json' ) | |
.then( JSON.parse ) | |
.then( data => this.set( data ) ); | |
} | |
}; | |
</script> |
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
{ | |
"name": "nadja" | |
} |
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
function get ( url ) { | |
return new Promise( function ( fulfil, reject ) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open( 'GET', url ); | |
xhr.onload = function () { | |
fulfil( xhr.responseText ); | |
}; | |
xhr.onerror = reject; | |
xhr.send(); | |
}); | |
} |
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
<main></main> | |
<script src='http://cdn.ractivejs.org/latest/ractive.js'></script> | |
<script src='https://rawgit.com/ractivejs/ractive-load/master/dist/ractive-load.js'></script> | |
<script src='get.js'></script> | |
<script> | |
Ractive.load( 'App.html' ).then( function ( App ) { | |
new App({ | |
el: 'main' | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment