1
00:00:00,960 --> 00:00:07,800
OK, let's change things up a little bit and pass some data to templates and organize things in a slightly

2
00:00:07,800 --> 00:00:09,720
more sophisticated fashion.

3
00:00:09,840 --> 00:00:10,670
Pretty easy right now.

4
00:00:10,680 --> 00:00:12,640
It's going to get a little more complex as time goes on.

5
00:00:12,780 --> 00:00:14,820
For the moment, this will suffice.

6
00:00:14,850 --> 00:00:20,160
So right now, I have everything in one file except for my templates.

7
00:00:20,160 --> 00:00:23,550
All of my go code exists in Main Dutko.

8
00:00:23,640 --> 00:00:28,860
And as you might expect, this will probably get more complex over time.

9
00:00:28,860 --> 00:00:31,760
And having everything stuck into one file, probably not a great idea.

10
00:00:32,130 --> 00:00:37,200
So I'm going to come over here to the root level of my directory and create a new go file and I'm going

11
00:00:37,200 --> 00:00:39,750
to call that handlers Dargo.

12
00:00:40,350 --> 00:00:44,780
And as you might expect, I'm going to put all of my handlers into this file.

13
00:00:44,790 --> 00:00:45,840
So let's go back to Main.

14
00:00:45,840 --> 00:00:51,890
Don't go and find these handlers, including rendered template, and I'll cut them out of here.

15
00:00:52,980 --> 00:01:00,090
And when I do, it says that my e-mail template is no longer being used and I can just reformat or manually

16
00:01:00,090 --> 00:01:00,690
delete that.

17
00:01:00,690 --> 00:01:07,710
And now I have I have a very simple, straightforward mango and is pointing to two functions which don't

18
00:01:07,710 --> 00:01:09,750
exist because I just cut them out of this file.

19
00:01:10,020 --> 00:01:12,150
So I'll just put them in here instead.

20
00:01:12,450 --> 00:01:15,600
And it will my ID automatically import these things.

21
00:01:15,600 --> 00:01:18,540
If yours doesn't, you have to put in this import statement.

22
00:01:18,870 --> 00:01:20,070
But everything is in here.

23
00:01:20,850 --> 00:01:26,640
So the one thing that's missing is goaland seems to have difficulty discovering what template we're

24
00:01:26,640 --> 00:01:27,300
talking about.

25
00:01:27,310 --> 00:01:35,850
So I'll just retype template parts files and then delete the extra text and then we'll add the import

26
00:01:35,850 --> 00:01:36,260
for me.

27
00:01:37,050 --> 00:01:37,540
All right.

28
00:01:38,190 --> 00:01:41,570
So and I've got to get rid of this there.

29
00:01:42,690 --> 00:01:47,360
So now I have two files and everything seems to be pretty much the same.

30
00:01:47,940 --> 00:01:52,800
My my main should have no errors and it doesn't my handlers has no errors and it doesn't.

31
00:01:53,190 --> 00:01:58,920
And if I try to run this application by going to my terminal window and doing what I did before, go,

32
00:01:58,950 --> 00:02:00,810
run Maeng go.

33
00:02:00,900 --> 00:02:07,710
It's not going to work and it's not going to work because it says, hey, in your mean go line 12,

34
00:02:07,710 --> 00:02:08,760
I don't know what home is.

35
00:02:08,760 --> 00:02:09,750
I don't know what a boat is.

36
00:02:10,320 --> 00:02:14,580
That's because we're just trying to compile if I use this command, go, run, mean go.

37
00:02:14,760 --> 00:02:16,920
It's just trying to compile mango.

38
00:02:16,920 --> 00:02:20,310
In fact I want it to compile all of the go directories.

39
00:02:20,340 --> 00:02:24,480
So I'm going to change that to say go, run, star, dot, go.

40
00:02:24,750 --> 00:02:27,840
And now when I run it, it should work beautifully.

41
00:02:27,840 --> 00:02:31,650
And if I go to my browser window and refresh there it is.

42
00:02:31,800 --> 00:02:32,410
Perfect.

43
00:02:32,520 --> 00:02:37,020
OK, so that's the first step is just to move things into separate files.

44
00:02:37,020 --> 00:02:43,650
And logically you should try to make functions in a given file all related to the same thing you're

45
00:02:43,650 --> 00:02:44,550
trying to accomplish.

46
00:02:44,820 --> 00:02:50,340
So in my main main goal, mean don't go file, all I'm doing is setting up my application.

47
00:02:50,820 --> 00:02:52,740
This will get more complex as time goes on.

48
00:02:52,740 --> 00:02:54,060
But for now, this is sufficient.

49
00:02:54,450 --> 00:02:59,250
In my handler's file, I'm just doing my handlers, except I have this render templates.

50
00:02:59,250 --> 00:03:04,920
If I wanted to, I could actually cut this out of here, create a new file under Hello World.

51
00:03:04,920 --> 00:03:10,500
I do go file called Render Ago and paste that in.

52
00:03:10,830 --> 00:03:13,620
And again, I have to tell it about HTML templates.

53
00:03:13,620 --> 00:03:16,740
So at this time I'll just go template HTML.

54
00:03:20,000 --> 00:03:23,530
HTML template is the way around HTML template.

55
00:03:23,600 --> 00:03:28,460
Here we go and go back to handlers and it deletes the things from my import.

56
00:03:28,460 --> 00:03:32,960
So if yours doesn't, you need to manually delete those to the remote no longer being used and now it's

57
00:03:32,960 --> 00:03:33,480
very clean.

58
00:03:33,500 --> 00:03:35,390
Now I have three files.

59
00:03:35,610 --> 00:03:37,340
Handlers are just handlers.

60
00:03:37,700 --> 00:03:45,950
Main is just my main main function and render just renders templates so I can now run the same thing

61
00:03:45,950 --> 00:03:47,990
and it will compile all three files.

62
00:03:47,990 --> 00:03:54,560
Go run Stadt, go compiles, render girl mango and handlers dutko and it should still work.

63
00:03:54,690 --> 00:03:56,210
Let's just verify that it does.

64
00:03:56,570 --> 00:03:57,360
Absolutely.

65
00:03:57,500 --> 00:04:02,540
Now this is a pretty ugly page and I'm going to make it a little bit prettier and I want to do that

66
00:04:02,540 --> 00:04:06,380
by using bootstrap a very, very popular siestas framework.

67
00:04:06,650 --> 00:04:10,250
And you get there by going to get bootstrap dotcom.

68
00:04:11,300 --> 00:04:21,230
And I want to get started and I'm going to very quickly just use this link here, which copies the bootstrap

69
00:04:21,230 --> 00:04:26,960
success, which is going to store my Web pages, and I'm going to go back and put this in my template.

70
00:04:27,230 --> 00:04:30,290
So let's go to templates and go to the home page.

71
00:04:30,560 --> 00:04:36,830
And I have to put this in the head section, so I'll paste it in and just to format it, I will automatically

72
00:04:36,830 --> 00:04:41,410
format things to put it so you can see it all on one screen and I'll do the same thing on the about

73
00:04:41,420 --> 00:04:41,840
page.

74
00:04:42,530 --> 00:04:46,430
And right away you should start thinking, well, this seems odd.

75
00:04:46,430 --> 00:04:49,940
Why do I have to have this information in two places?

76
00:04:49,940 --> 00:04:53,560
Can I just put it in one and have all of my templates use that?

77
00:04:53,570 --> 00:04:53,990
Yes.

78
00:04:53,990 --> 00:04:54,230
Yes.

79
00:04:54,230 --> 00:04:56,600
In fact, you can and will be doing that shortly.

80
00:04:56,840 --> 00:05:00,510
But right now, let's just go back and see what that did to that change anything.

81
00:05:01,160 --> 00:05:04,690
So go back to my Web browser and reload this page.

82
00:05:04,700 --> 00:05:05,300
Will it change?

83
00:05:05,300 --> 00:05:07,460
The font doesn't look great, though.

84
00:05:07,460 --> 00:05:09,620
It's all jammed up in the left hand corner.

85
00:05:10,280 --> 00:05:13,520
What we can put a little bit of styling in here just to make it look a little bit better.

86
00:05:13,970 --> 00:05:15,980
And we'll be doing more of this as time goes on.

87
00:05:15,980 --> 00:05:20,860
But I'll just give you the very basics right now in order to make my homepage look a little bit better.

88
00:05:20,900 --> 00:05:26,030
I don't just stick these tags, the header tag in the paragraph, tag in the body tag.

89
00:05:26,060 --> 00:05:27,470
They should be wrapped in something.

90
00:05:27,890 --> 00:05:30,440
And again, I'm using Emet just to save some typing.

91
00:05:30,440 --> 00:05:37,550
But the very first thing you need to do is wrap your body content in a div with the class of container.

92
00:05:38,790 --> 00:05:40,790
Oops, there we go.

93
00:05:41,570 --> 00:05:51,350
And inside of that you have to have a row a div with a class of row and inside of that you have one

94
00:05:51,350 --> 00:05:52,310
or more columns.

95
00:05:52,310 --> 00:05:59,250
I'm just going to have one column for right now, so I'll put div class of call and Emet helpfully types

96
00:05:59,250 --> 00:06:06,380
that all out for me and then I grab these things and put them in those three nested device and when

97
00:06:06,380 --> 00:06:09,950
I go back and reload the homepage that's a little bit better.

98
00:06:09,980 --> 00:06:11,480
OK, it's still too close to the top.

99
00:06:11,480 --> 00:06:16,070
Maybe I want to picture up there, but right now things are starting to look a little bit cleaner.

100
00:06:16,550 --> 00:06:21,110
And of course I can do the same thing in my about page so I can copy all of that.

101
00:06:21,380 --> 00:06:29,630
Go to my about page and I will just put this in here and cut this and put this in here.

102
00:06:30,380 --> 00:06:32,420
And I see a missing a closing body tag.

103
00:06:32,420 --> 00:06:34,760
I probably should have that and format the whole thing.

104
00:06:35,090 --> 00:06:41,150
And now when I go to about slash about that should have the same kind of styling and it does.

105
00:06:41,180 --> 00:06:41,620
All right.

106
00:06:42,260 --> 00:06:46,610
So what we've done so far, it's just a clean things up a little bit, make things a little bit more

107
00:06:46,610 --> 00:06:47,870
straightforward now.

108
00:06:47,870 --> 00:06:50,930
There's a lot more we can do and a lot more we will do.

109
00:06:52,280 --> 00:06:58,580
Let's think about, first of all, how are we going to make this content, all of this stuff that doesn't

110
00:06:58,580 --> 00:07:04,400
change from page to page, all of this head section, including the body, all of this is the same in

111
00:07:04,400 --> 00:07:08,780
every page and so is the closing body tag and the closing HTML tag.

112
00:07:09,230 --> 00:07:16,610
Well, we can actually do that using templates, using the template system built in to go by establishing

113
00:07:16,610 --> 00:07:23,180
a layout and then having all of the pages that are going to use that layout, basically import that.

114
00:07:23,570 --> 00:07:24,920
So we'll do that in the next lecture.

115
00:07:24,920 --> 00:07:28,400
It's very straightforward and then we'll start passing some data to these templates.

116
00:07:29,510 --> 00:07:30,350
That's enough for now.
