-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.js
73 lines (63 loc) · 2.16 KB
/
view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Renderer {
constructor(data) {
this.user = data.mainUser
this.friends = data.usersArray
this.quote = data.quote
this.pokemon = data.pokemon
this.meat = data.aboutMe
}
renderUser(){
$('.user-container').empty()
const source = $('#user-template').html();
const template = Handlebars.compile(source);
const newHTML = template({user: this.user})
$('.user-container').append(newHTML)
}
renderFriends(){
$('.friends-container').empty()
const source = $('#friends-template').html();
const template = Handlebars.compile(source);
const newHTML = template({friend: this.friends})
$('.friends-container').append(newHTML)
}
renderQuote(){
$('.quote-container').empty()
const source = $('#quote-template').html();
const template = Handlebars.compile(source);
const newHTML = template(this.quote)
$('.quote-container').append(newHTML)
}
renderPokemon(){
$('.pokemon-container').empty()
const source = $('#pokemon-template').html();
const template = Handlebars.compile(source);
const newHTML = template({pokemon: this.pokemon})
$('.pokemon-container').append(newHTML)
}
renderMeat(){
$('.meat-container').empty()
const source = $('#meat-template').html();
const template = Handlebars.compile(source);
const newHTML = template({aboutMe: this.meat})
$('.meat-container').append(newHTML)
}
renderAll(){
this.renderUser()
this.renderFriends()
this.renderQuote()
this.renderPokemon()
this.renderMeat()
}
renderSaved(saved){
const namearr = saved.map(u => u.mainUser.first + ' ' + u.mainUser.last)
$('.saved-container').empty()
const source = $('#saved-template').html();
const template = Handlebars.compile(source);
const newHTML = template(namearr)
$('.saved-container').append(newHTML)
}
}
Handlebars.registerHelper('properCase', function(text)
{
return text[0].toUpperCase() + text.substring(1)
});