Created
May 11, 2011 23:26
-
-
Save locks/967617 to your computer and use it in GitHub Desktop.
Nham
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
| <html> | |
| <head> | |
| <script type="text/javascript" charset="utf-8" src="milk.min.js"></script> | |
| <script type="text/javascript" charset="utf-8" src="weld.js"></script> | |
| <style> | |
| body { background : #333; | |
| color : #fff; } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="classy" style="float: left"> | |
| <p>This</p> | |
| </div> | |
| <div class="welded" style="margin-left: 50%"> | |
| <h1 class="title"></h1> | |
| <h2 class="subtitle"></h2> | |
| <ul class="regions"> | |
| <li class="name"></li> | |
| <li class="age"></li> | |
| <li> | |
| <ul> | |
| <li class="list"></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| <span class="treasure"> | |
| { <span class="x"></span> , <span class="y"></span> , <span class="z"></span> } | |
| </div> | |
| <script type="text/javascript" charset="utf-8"> | |
| var html ="<h1>{{title}}</h1> \ | |
| <h2>{{subtitle}}</h2>\ | |
| <ul>{{#regions}}\ | |
| <li>{{name}}</li>\ | |
| <li>{{age}}</li>\ | |
| <li>\ | |
| <ul>\ | |
| {{#list}}\ | |
| <li>{{.}}</li>\ | |
| {{/list}}\ | |
| </ul>\ | |
| </li>\ | |
| {{/regions}}</ul>\ | |
| </ul>\ | |
| {{#treasure}}\ | |
| { {{x}} , {{y}} , {{z}} }\ | |
| {{/treasure}}" | |
| var data = { title : "Ahoy" | |
| , subtitle : "me mateys!" | |
| , regions : [ | |
| { name : 'john' | |
| , age : 30 | |
| , list : [1,2,3,4] } | |
| , | |
| { name : 'silver' | |
| , age : 123 | |
| , list : [5,6,7,8] } | |
| ] | |
| , treasure : { x : 30 | |
| , y : 50 | |
| , z : 3 } | |
| } | |
| var text = document.getElementById("classy"); | |
| text.innerHTML = Milk.render(html, data); | |
| weld(document.querySelector('.welded'), data); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment