Skip to content

Instantly share code, notes, and snippets.

@pure
Created December 6, 2009 10:08
Show Gist options
  • Save pure/250142 to your computer and use it in GitHub Desktop.
Save pure/250142 to your computer and use it in GitHub Desktop.
Directive - Assign a value
<html>
<head>
<title>PURE Unobtrusive Rendering Engine</title>
<script src="../libs/jquery.js"></script>
<script src="../libs/pure.js"></script>
</head>
<body>
<!-- HTML template -->
<div class="template">
Hello <a></a>
</div>
<script>
var data = {'who':'BeeBole!', site:'http://beebole.com'},
directive = {
// look for the tag 'a' and place the value of
// the property 'who' in its node value
'a':'who',
// look for the tag a, and set its attribute 'href'
// to the value of the property 'site'
'a@href':'site'
}
// note the use of render instead of autoRender and the 2nd
// parameter with directive
$('div.template').render(data, directive);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment