1 | # Fastify + Marko
|
2 |
|
3 | See the [marko-fastify](https://github.com/marko-js-samples/marko-fastify) sample
|
4 | project for a fully-working example.
|
5 |
|
6 | ## Installation
|
7 |
|
8 | ```bash
|
9 | npm install fastify --save
|
10 | npm install point-of-view --save
|
11 | npm install marko --save
|
12 | ```
|
13 |
|
14 | ## Usage
|
15 |
|
16 | ```js
|
17 | const fastify = require("fastify")();
|
18 |
|
19 | fastify.register(require("point-of-view"), {
|
20 | engine: {
|
21 | marko: require("marko")
|
22 | }
|
23 | });
|
24 |
|
25 | fastify.get("/", (req, reply) => {
|
26 | reply.view("/index.marko", {
|
27 | name: "Frank",
|
28 | count: 30,
|
29 | colors: ["red", "green", "blue"]
|
30 | });
|
31 | });
|
32 |
|
33 | fastify.listen(8080, err => {
|
34 | if (err) throw err;
|
35 | console.log(`Server listening on ${fastify.server.address().port}`);
|
36 | });
|
37 | ```
|