Michelle Bergquist
Librarian gone Web Dev.
- Describe server side rendering
- Name a benefit of template engines
- List 3 HBS helpers
Handlebars
Jade
EJS
Mustache
Dust
5
We can use variables, if-helpers, each-helpers.
<h1> {{variableName}} </h1>
<section>
{{#if name}}
<h1> Hello {{name}} </h1>
{{else}}
<h1> I don't know your name </h1>
{{/if}}
</section>
<section class= 'fav foods'>
<ol>
{{#each foods}}
<li> {{this}} </li>
{{/each}}
</ol>
</section>
app.get('/', (req, res) => {
res.render ('index', {
name: 'Michelle',
foods: [
'pizza',
'ice cream',
'kale'
]
})
})
1. Build out a basic express server
2. Add a route for /
that sends the words `hello world`
2. Add hbs as view engine, pass data to render
- Describe server side rendering
- Name a benefit of template engines
- List 3 HBS helpers
Create an express-HBS site that displays the following data about yourself!
Add an if statement.
const favorites = {
name: ' ',
color: ' ',
season: ' ',
foods: [' ', ' ']
}
By Michelle Bergquist
Supplemental deck for a galvanize lesson