Skip to content

Instantly share code, notes, and snippets.

@deontologician
Created June 3, 2015 20:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deontologician/05daec884ca71decb90e to your computer and use it in GitHub Desktop.
Save deontologician/05daec884ca71decb90e to your computer and use it in GitHub Desktop.
coffeescript virtual-hyperscript
# Example of virtual hyperscript in coffeescript
# See: https://github.com/Matt-Esch/virtual-dom/blob/master/virtual-hyperscript/README.md
render_shard = (shard, index) =>
h "li.shard", [
h "div.shard-heading", [
h "span.shard-title", ["Shard #{index + 1}"]
h "span.numkeys", ["~#{approximate(shard.num_keys)} documents"]
]
h "ul.replicas", shard.replicas.map(render_replica)
]
render_replica = (replica) =>
h "li.replica", [
h "span.server-name.#{state_color(replica.state)}", [
h "a", href: "#servers/#{replica.id}", [replica.server]
]
h "span.replica-role.#{replica_role(replica)}", [
replica_rolename(replica)
]
h "span.state.#{state_color(replica.state)}", [replica.state]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment