Created
December 23, 2014 15:56
-
-
Save teaplanet/57e249dc2c77840829d0 to your computer and use it in GitHub Desktop.
Ractive.js Tutorial 3-3
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/expressions/3 --> | |
| <script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script> | |
| <div id='container'></div> | |
| <script id='template' type='text/ractive'> | |
| <p>red:</p> | |
| <div style='background-color: red; width: {{red * 100}}%;'></div> | |
| <p>green:</p> | |
| <div style='background-color: green; width: {{green * 100}}%;'></div> | |
| <p>blue:</p> | |
| <div style='background-color: blue; width: {{blue * 100}}%;'></div> | |
| <p><strong>result:</strong></p> | |
| <div style='background-color: rgb({{Math.round(red * 255)}}, {{Math.round(green * 255)}}, {{Math.round(blue * 255)}})'> | |
| </div> | |
| </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: { | |
| red: 0.45, | |
| green: 0.61, | |
| blue: 0.2 | |
| } | |
| }); | |
| // ractive.set('red', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment