Source: Javascript Templating Language and Engine— Mustache.js with Node and Express Reference: Mustache.js documentation
Templating: fast/efficinet way to render client templates with a JSON data source.
Mustache.render("Hello, ", {name: "Logan"});
//returns: Hello, Logan
$ npm install mustache --save
server.js/app.js/index.js
filevar mustacheExpress = require('mustache-express');
// Register '.mustache' extension w/ The Mustache Express
app.engine('html', mustacheExpress());
app.set('view engine', 'html');
app.set('views', _dirname + '/src/views');
- /views
-- book.html
-- hello.html
-- index.html
In hello.html:
<div class="container mt-5 mb-5 p-5" style='background-color: white; opacity: 0.9'>
<h1>Hello </h1>
</div>
res.render(TEMPLATE_NAME, JSON_DATA)
res.render('hello', name)
var nameObject = {"name": "Logan"}
res.renger('hello', nameObject)
Source: A Complete Guide to Flexbox
Gives container ability to alter its items’ width/size and order to fill avaliable space.
main-axis
primary axis (horizonal, but depends on flex-direction
)main-start
& main-end
where the items start/end (like margin)main-size
flex items width or height control main’s size (height if main-axis is horizonal)cross-axis
Perpendicular axis to maincross-start
& cross-end
where item start/end on cross-axiscross-size
flex items width or height control cross-size (width if cross-axis is vertical)display
defines a flex container
.container {
display: flex; /* or infline-flex */
}
flex-direction
establishes main axis
.container {
flex-direction: row | row-reverse | column | column-reverse;
}
flex-wrap
allows items to move to new line as needed
.container {
flex-wrap: nowrap | wrap | wrap-reverse; /*reverse goes bottom to top*/
}
flex-flow
shorthand for both flex-direction
and flex-wrap
.container {
flex-flow: column wrap;
}
justify-content
defines alignment along main-axis
flex-start
default, items packed at startflex-end
packed toward endcenter
centeredspace-between
spaced evenly (no side margin)spae-around
evenly space with small side marginspace-evenly
equal spacing all around.container {
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;
}
align-items
defines alignment along cross-axis
flex-start
flex-end
center
stretch
baseline
.container {
align-items: stretch | flex-start | flex-end | center | baseline | first baseline | last baseline | start | end | self-start | self-end + ... safe | unsafe;
}
flex-start
flex-end
center
stretch
space-between
space-around
.container {
align-content: flex-start | flex-end | center | space-between | space-around | space-evenly | stretch | start | end | baseline | first baseline | last baseline + ... safe | unsafe;
}
order
can set number to define order.item {
order: 5; /* default is 0 */
}
flex-grow
ability for item to grow if necessary. Amount is proportional. (e.g. if all 1, they take up 1/x).
.item {
flex-grow: 4; /* default 0 */
}
flex-shrink
ability to shrink if necessary.item {
flex-shrink: 3; /* default 1 */
}
flex-basis
size of item before remaining space distributed (20% / 5rem/ etc).item {
flex-basis: | auto; /* default auto */
}
flex
shorthandn for flex-grow / flex-shrink / flex-basis recommended
0 1 auto
.item {
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
}
align-self
change alignment for single item
.item {
align-self: auto | flex-start | flex-end | center | baseline | stretch;
}
.parent {
display: flex;
height: 300px; /* Or whatever */
}
.child {
width: 100px; /* Or whatever */
height: 100px; /* Or whatever */
margin: auto; /* Magic! */
}