Skip to content

Instantly share code, notes, and snippets.

@djadriano
Created June 25, 2014 23:35
Show Gist options
  • Select an option

  • Save djadriano/7e2e97e68f1ac7cfee7f to your computer and use it in GitHub Desktop.

Select an option

Save djadriano/7e2e97e68f1ac7cfee7f to your computer and use it in GitHub Desktop.
.first-events table tr {
display: none;
}
.first-events table tr:not(:nth-child(4)) {
display: block;
}
.second-events table tr:nth-child(2),
.second-events table tr:nth-child(3),
.second-events table tr:nth-child(4) {
display: none;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://jashkenas.github.io/underscore/underscore-min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h2>Agenda</h2>
<script id="header" type="text/x-handlebars-template">
<table cellpadding="3" cellspacing="1" border="1">
<tr>
<td>Horário</td>
<td>Sessão</td>
</tr>
{{#each event.schedule}}
<tr>
<td><time>{{time}}</time></td>
<td>{{description}}</td>
</tr>
{{/each}}
</table>
</script>
<div class="first-events"></div><br>
<div class="second-events"></div>
<h2>Palestrantes</h2>
<script id="speakers" type="text/x-handlebars-template">
<ul>
{{#each event.speakers}}
<li id="{{id}}" data-speaker-id="{{id}}" data-speaker-name="{{name}}">
<div>
<figure>
<img alt="{{name}}" src="{{thumb}}" />
</figure>
<dl class="speaker-name-info">
<dt>{{name}}</dt>
<dd>
<p>{{occupation}}</p>
<p>
<a href="#" class="nav_toogle_bio">Bio</a>
</p>
</dd>
</dl>
<div class="bio">
{{bio}}
<p class="close-bio">Fechar</p>
</div>
</div>
</li>
{{/each}}
</ul>
</script>
<div class="speakers-list"></div>
</body>
</html>
var data = {
event: {
schedule: [
{
time: '09:00',
description: 'title event'
},
{
time: '10:00',
description: 'title event 2'
},
{
time: '11:00',
description: 'title event 3'
},
{
time: '12:00',
description: 'title event 4'
}
],
speakers: [
{
id : '1',
name : 'Roy',
occupation : 'Developer',
bio : 'Doidão',
thumb : ''
}
]
}
};
var source = $("#header").html();
var template = Handlebars.compile(source);
var source_speakers = $("#speakers").html();
var template_speakers = Handlebars.compile(source_speakers);
$(".first-events").html(template(data));
$(".second-events").html(template(data));
$(".speakers-list").html(template_speakers(data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment