Skip to content

Instantly share code, notes, and snippets.

@m242
Created December 22, 2011 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m242/1511833 to your computer and use it in GitHub Desktop.
Save m242/1511833 to your computer and use it in GitHub Desktop.
Hogan-CouchDB
<!DOCTYPE html>
<html>
<head>
<title>Activity Test</title>
</head>
<body>
<div id="output"></div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://twitter.github.com/hogan.js/1.0.0/hogan.js"></script>
<script type="text/javascript">
$(function() {
var template, wall;
template = Hogan.compile($("#activityTemplate").html());
wall = function() {
$.get("http://www.skechers.com/wall/init?callback=?", function(data) {
$("#output").html(template.render(data));
}, "jsonp");
};
wall();
// Run the wall function every 3 seconds.
setInterval(function() { wall(); }, 3000);
});
</script>
<!--
The CouchDB object looks like:
{ "results": [
{ "doc": {
"action": {
"link": "/style/12345/product-name/clr",
"name": "Women's Keepsakes - Postage"
}
}
}
]
}
-->
<script type="text/x-skechers" id="activityTemplate">
{{#results}}
<h2><a href="http://www.skechers.com{{ doc.action.link }}">{{ doc.action.name }}</a></h2>
{{/results}}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment