Created
November 9, 2013 21:15
-
-
Save pure/7390139 to your computer and use it in GitHub Desktop.
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://pure.github.io/pure/libs/pure.js"></script> | |
</head> | |
<body> | |
<div class="test"> | |
<ul> | |
<li class="car"> | |
<ul> | |
<li class="accessory"> | |
<span></span> | |
</li> | |
</ul> | |
</li> | |
</ul> | |
</div> | |
<script> | |
var data = { | |
cars:[ | |
{brand:'bmw', accessories:[{name:'air conditionning'}, {name:'automatic'}]}, | |
{brand:'land rover', accessories:[{name:'heating system'}, {name:'surround sound'}]} | |
], | |
selectedBrand:'land rover' | |
}, | |
dir = { | |
'li.car':{ | |
'car<-cars':{ | |
'li.accessory':{ | |
'accessory<-car.accessories':{ | |
'span':function(a){ | |
return a.car.item.brand + ': ' + a.accessory.item.name; | |
} | |
} | |
} | |
}, | |
filter:function(a){ | |
return this.brand === a.context.selectedBrand; | |
} | |
} | |
}; | |
$('.test').render(data, dir); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment