All right guys. 1
Here comes the challenge 2
number 2. Are you ready? 3
All right. 4
So in the app.js when you first downloaded it we had three of these constants at the top and 5
they just contain a whole bunch of Lorem Ipsum and randomly generated text. 6
But let's say that this is some content that's in our server and we want to be able to deliver it over 7
to our home page using EJS. 8
Now this challenge is about doing exactly that. 9
How much can you make this home starting content be displayed inside our home page inside a paragraph 10
tag so that when you head over to our home page on localhost:3000 you not only get the h1 that says 11
home, but also the same text that's held inside that constant which is home starting content? 12
So that's the challenge. Pause the video now and give it a go. 13
All right. 14
So currently inside home.ejs 15
all that we have is an h1 tag. 16
Now in order to complete this challenge we need to also have a paragraph element in here. And the text 17
that's going to go into that paragraph element is going to be the text that's inside home starting content. 18
So you'll need to render that variable using the correct EJS tag in order to see the content in this 19
page. 20
So with that hint and maybe a little bit of googling around what we just talked about, see if you 21
can complete the challenge now. 22
All right. 23
Here's my second hint. 24
So we know that we need to have a paragraph element in here. And in between the paragraph element is the 25
text that we want to show up on our Web page. 26
So the text that we want is going to be rendered dynamically using EJS. And to do that we need the 27
EJS tag that does that. 28
So if we head over to the EJS docs, you can see the tag that we've been using so far which is the one 29
that outputs the value of a variable into the template. And it's in fact even the one that they show 30
in the header. And in between that tag is going to be the name of the variable that you passed over to 31
the EJS template. 32
So with that hint see if you can now complete the challenge. 33
OK. 34
This is hint number 3. Inside this paragraph tag 35
let's add that EJS tag that we showed you earlier on the one with a angle, a percentage sign and 36
an equal sign in the closing part of the tag is just a percentage sign and an angle bracket. 37
Now in between these two parts is going to be in the name of the variable that we're going to pass into 38
here. 39
So let's give it a name. Let's call it just starting content. 40
And now we need to pass over a variable with that name to our home. 41
ejs from our server, our app.js. 42
So see if with that hint you can now complete the challenge. 43
All right. 44
This is my fourth and final hint. 45
Currently our res.render method is only rendering the home.ejs page. 46
If we wanted to pass in a variable, we would add a comma and then we would pass over a Javascript object. 47
So we know that Javascript objects are a key value pairs that are inside a set of curly braces. 48
So you need to provide a key and a value. 49
The key is going to be the variable that you'll be able to tap into 50
inside your home. 51
ejs and the value is whatever it is that you want to pass over that comes from this current page which 52
is the app.js. 53
Now with my final hint see if you can now finally complete the challenge.