1
00:00:02,070 --> 00:00:05,700
And that's now it for this course section.

2
00:00:05,700 --> 00:00:07,160
In this course section,

3
00:00:07,160 --> 00:00:12,120
the biggest new feature was of course the additional EJS

4
00:00:12,120 --> 00:00:14,800
of this template language

5
00:00:14,800 --> 00:00:19,800
that allows us to build these enhanced HTML files,

6
00:00:20,100 --> 00:00:21,490
as we could call them,

7
00:00:21,490 --> 00:00:26,400
where we do have our regular HTML code as we know it

8
00:00:26,400 --> 00:00:28,270
with all the features we learned,

9
00:00:28,270 --> 00:00:31,780
but where we got this extra syntax available,

10
00:00:31,780 --> 00:00:33,950
this EJS syntax,

11
00:00:33,950 --> 00:00:38,840
that allows us to actually change the generated HTML content

12
00:00:38,840 --> 00:00:41,040
dynamically on the server.

13
00:00:41,040 --> 00:00:43,000
And we need something like this

14
00:00:43,000 --> 00:00:47,400
to build real websites with dynamic content.

15
00:00:47,400 --> 00:00:50,350
If your website has no dynamic content,

16
00:00:50,350 --> 00:00:53,350
if you just build something like a portfolio page,

17
00:00:53,350 --> 00:00:56,310
then you won't need a template engine,

18
00:00:56,310 --> 00:00:59,920
you might not even need any server-side code.

19
00:00:59,920 --> 00:01:03,820
But if your website has some user-generated content

20
00:01:03,820 --> 00:01:07,910
or some products that change whilst the page is online

21
00:01:07,910 --> 00:01:09,950
and users are visiting it,

22
00:01:09,950 --> 00:01:12,090
whenever you have any kind of content

23
00:01:12,090 --> 00:01:14,380
that's not static but dynamic,

24
00:01:14,380 --> 00:01:16,550
you need a server-side language

25
00:01:16,550 --> 00:01:18,790
to handle that dynamic content.

26
00:01:18,790 --> 00:01:21,570
And you typically need a template engine

27
00:01:21,570 --> 00:01:24,723
to produce dynamic HTML files.

28
00:01:25,660 --> 00:01:28,220
Now you also saw that we got more benefits

29
00:01:28,220 --> 00:01:30,800
than just the dynamic content.

30
00:01:30,800 --> 00:01:32,830
For example, with these includes,

31
00:01:32,830 --> 00:01:36,740
we can also avoid unnecessary code duplication

32
00:01:36,740 --> 00:01:41,740
and we can split our HTML code into smaller reusable pieces,

33
00:01:43,100 --> 00:01:47,080
which makes working on large HTML code bases

34
00:01:47,080 --> 00:01:48,743
easier and more convenient.

35
00:01:49,890 --> 00:01:52,080
Now besides this include feature,

36
00:01:52,080 --> 00:01:55,870
EJS also allows us to output values

37
00:01:55,870 --> 00:01:57,270
like we're doing it here.

38
00:01:57,270 --> 00:02:00,500
As you learned, it then escapes these values

39
00:02:00,500 --> 00:02:05,020
so that any value we output is treated as raw text

40
00:02:05,020 --> 00:02:07,520
unless we use this minus,

41
00:02:07,520 --> 00:02:10,410
this dash here with the EJS syntax,

42
00:02:10,410 --> 00:02:12,590
like we do it for including.

43
00:02:12,590 --> 00:02:16,270
In that case, any HTML content that is encountered

44
00:02:16,270 --> 00:02:21,080
will be treated and rendered as HTML content.

45
00:02:21,080 --> 00:02:23,290
And in EJS, we can also,

46
00:02:23,290 --> 00:02:26,310
besides outputting content in HTML,

47
00:02:26,310 --> 00:02:30,840
also run JavaScript logic like adding an if statement

48
00:02:30,840 --> 00:02:33,240
to render different pieces of content

49
00:02:33,240 --> 00:02:35,610
based on different conditions.

50
00:02:35,610 --> 00:02:38,920
Or we use loops to repeat content

51
00:02:38,920 --> 00:02:42,223
and output multiple restaurants or whatever you have.

52
00:02:43,470 --> 00:02:44,720
Always keep in mind

53
00:02:44,720 --> 00:02:48,590
that what arrives on the front end in the browser

54
00:02:48,590 --> 00:02:51,420
is the finished HTML code.

55
00:02:51,420 --> 00:02:54,800
Here, you won't see that server-side logic.

56
00:02:54,800 --> 00:02:57,640
You won't see that EJS syntax.

57
00:02:57,640 --> 00:02:59,220
Here on the client,

58
00:02:59,220 --> 00:03:02,760
you really just get the finished HTML code.

59
00:03:02,760 --> 00:03:05,890
Now besides the EJS template language,

60
00:03:05,890 --> 00:03:08,430
we also talked about static files

61
00:03:08,430 --> 00:03:12,210
that don't need to be generated or touched on the server,

62
00:03:12,210 --> 00:03:16,250
specifically the CSS and JavaScript files.

63
00:03:16,250 --> 00:03:20,060
With Express, we can easily serve such static files

64
00:03:20,060 --> 00:03:23,970
with help of the built-in static middleware method here,

65
00:03:23,970 --> 00:03:26,100
which we can use to serve the content

66
00:03:26,100 --> 00:03:27,740
of a specific folder,

67
00:03:27,740 --> 00:03:30,050
in this case here, the public folder,

68
00:03:30,050 --> 00:03:32,660
without any further questions.

69
00:03:32,660 --> 00:03:34,570
Therefore, of course, you should make sure

70
00:03:34,570 --> 00:03:37,200
that you only put files into that folder

71
00:03:37,200 --> 00:03:40,460
that should be accessible by every user of your website,

72
00:03:40,460 --> 00:03:42,830
like style files or images.

73
00:03:42,830 --> 00:03:45,860
And with that, we acquired more powerful tools

74
00:03:45,860 --> 00:03:48,060
that we need to build real websites,

75
00:03:48,060 --> 00:03:49,330
and we're now prepared

76
00:03:49,330 --> 00:03:52,590
to take yet another step deeper into Express

77
00:03:52,590 --> 00:03:53,963
and web development.

