New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Views: Write Draft For Introduction #27618
Conversation
Removed the sentence stating that "views are the UI that the user interacts with", which I thought might be misleading.
Added an explanation that views need to be rendered at the end of controller functions.
I was unable to get the example to work using the Script tag, so this example will be rewritten with a different method of passing data.
Previously the EJS with Express example was written with data defined in a script tag. However this did not work, and so was modified such that data is defined in app.js, and passed down into the navbar component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasonHYLam Amazing lesson 🔥 🔥 🔥
I've left a lot of comments, check them out below.
I particularly like the reusable section and the code examples are great as well. This is going to be a great addition to the curriculum.
nodeJS/express/views.md
Outdated
<div class="lesson-content__panel" markdown="1"> | ||
|
||
1. A RESOURCE ITEM | ||
- AN INSTRUCTION ITEM | ||
1. A PRACTICE ITEM | ||
- A TASK ITEM | ||
|
||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add relevant documentation from the Express site, and a couple of practice assignment items, like: "Add a view for an about page which should render on the /about
route"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just added a few assignment items, including a resource from Express regarding template engines (I've addressed that it uses Pug rather than EJS), and to create and add some components. Sorry for the delay!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
Co-authored-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
Co-authored-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
Co-authored-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
nodeJS/express/views.md
Outdated
1. Read through the [Express resource on template engines](https://expressjs.com/en/guide/using-template-engines.html). The resource uses Pug for the examples which has a different syntax, however the information should still be a useful supplement to this lesson. | ||
2. Add a view for an about page, which should render on the `/about` route. | ||
3. Create a reusuable footer component and render it in the `/` route. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linting errors here will need addressing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the linting error is, is it regarding the extra space at end of the 3rd line? I'll resolve that but please let me know if there are any other errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 3 linting errors for this part at not using lazy numbering for ordered lists and the trailing space at the end of line 163.
You can see the linting errors as annotations in the Files changed
tab up top.
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
Just a note that we're not really sure why GitHub is flagging the "unchanged files with check annotations" thing all of a sudden (it's happened midway through a few other PRs as well). Not entirely sure if there's anything we can do on our end since it's a GH beta feature (but there've already been issues elsewhere from other annoyed people about the feature XD Would be nice if they just noted those files but not also force an action run on them, contaminating the PR with unrelated files...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly just linting/formatting-related matters.
There are also still a fair few mentions of "components" which will probably be better called "templates" as per the docs' terminology.
Amazing work, I really must stress. These are all mainly just consistency/style things.
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
…it-test into node_revamp
<div class="lesson-note lesson-note--tip" markdown="1"> | ||
|
||
#### Directories within the views folder | ||
|
||
We can have nested directories of EJS template files within the views. For example, to render the template file `./views/user/show.ejs`, we'll need to provide the relative path like so: | ||
|
||
```javascript | ||
// in res.render | ||
res.render("user/show"); | ||
|
||
// in include | ||
include("user/show"); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting that, I've added a closing div tag just above Serving Static Assets. Let me know if that's correct or if it was needed somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 🚀 🚀
Because
This is a draft of the introduction of the new "Views" lesson for the NodeJS revamp.
This PR
Issue
Related to #27616
Closes #XXXXX
Additional Information
Pull Request Requirements
location of change: brief description of change
format, e.g.Intro to HTML and CSS lesson: Fix link text
Because
section summarizes the reason for this PRThis PR
section has a bullet point list describing the changes in this PRIssue
section