Created
December 23, 2014 11:25
-
-
Save teaplanet/41bf0c041e786a0ed17e to your computer and use it in GitHub Desktop.
Ractive.js Tutorial 2-2
This file contains hidden or 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
| <!-- http://learn.ractivejs.org/nested-properties/2 --> | |
| <script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script> | |
| <div id='container'></div> | |
| <script id='template' type='text/ractive'> | |
| <h2>Country profile</h2> | |
| {{#with country}} | |
| <p>{{name}} is a {{climate.temperature}} country with {{climate.rainfall}} rainfall and a population of {{population}}.</p> | |
| {{#with capital}} | |
| <p>The capital city is {{name}} (<a href='https://maps.google.co.uk/maps/place/{{name}}/@{{lat}},{{lon}},12z' target='_blank'>see map</a>).</p> | |
| {{/with}} | |
| {{/with}} | |
| {{#country}} | |
| '#' instead of 'with'. | |
| {{/country}} | |
| </script> |
This file contains hidden or 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
| var ractive = new Ractive({ | |
| el: 'container', | |
| template: '#template', | |
| data: { | |
| country: { | |
| name: 'The UK', | |
| climate: { temperature: 'cold', rainfall: 'excessive' }, | |
| population: 63230000, | |
| capital: { name: 'London', lat: 51.5171, lon: -0.1062 } | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment