fastify / point-of-view Goto Github PK
View Code? Open in Web Editor NEWTemplate rendering plugin for Fastify
License: MIT License
Template rendering plugin for Fastify
License: MIT License
Getting the following error when rendering a view using the [email protected]
engine:
{
"level": 50,
"time": 1545039516427,
"msg": "cb is not a function",
"pid": 5396,
"hostname": "goliatorum.home",
"reqId": 1,
"req": {
"id": 1,
"method": "GET",
"url": "/login",
"hostname": "127.0.0.1:3003",
"remoteAddress": "127.0.0.1",
"remotePort": 53826
},
"res": { "statusCode": 500 },
"err": {
"type": "TypeError",
"message": "cb is not a function",
"stack": "TypeError: cb is not a function\n at Function.compile (/src/node_modules/ejs-mate/lib/index.js:130:3)\n at _readCallback (/src/node_modules/point-of-view/index.js:139:39)\n at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:528:3)"
},
"v": 1
}
This is due to ejs-mate
expecting a callback in their compile function:
function compile(file, options, cb)
Missing type-definition for typescript usage. Will try to help with that.
2.12.0
to 2.12.1
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
fastify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
π PR:
setErrorHandler
(#2092)this
to the not found handler (#2102)The new version differs by 14 commits.
c4a83ae
Bumped v2.12.1
350f00b
docs: Clarify reply.redirect status code docs (#2121)
a378dd5
Added fastify-axios plugin (#2118)
093947b
http2: fix req.hostname not set (#2113)
6f79a90
fix: multiple route same schema (#2108)
98ca7fd
docs: fix header and body generic types (#2103)
772cf5e
types: add type of this
to the not found handler (#2102)
b44d859
docs: use computed key when assigning property to request (#2100)
da4c89d
Fixed typo res.res to reply.res (#2099)
743ad74
Fix inaccurate type of setErrorHandler
(#2092)
f971751
chore: greenkeeper ignore semver (#2095)
41cd02f
Throws error if an invalid status code is sent (#2082)
14b4e02
add comma to queryStringJsonSchema (#2085)
1c52b9f
Added fastify-esso plugin (#2084)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
I think test.js is becoming very hard to maintain as there is a lot of duplicated code. I think we should split into multiple files and create some helpers to reduce code duplication as much as possible.
I recently migrated my app from express to fastlify. It's awesome what it did performance wise π
I'm using Handlebars as my view engine, using a layouts/main.hbs
which has all the boilerplate code. (Head, Loading Spinner, etc.)
But how can I configure point-of-view to use the main layout by default?
I tried it using all options with no success...
3.1.3
to 3.1.4
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
nunjucks is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 7 commits.
11262e5
Release v3.1.4
bcd45fc
Merge pull request #1165 from stigkj/master
40480f0
Fix engine version for Node v11.1.0
3512ca6
Merge pull request #1161 from jonathanchu/master
9dc07dc
Fix dependency version for node v11.0.0
39bb716
Merge pull request #1126 from TheDancingCode/issue-126
4d4dc40
Escape unicode newlines when compiling
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
I think it's due that we improve the support for async/await in this module.
Currently, it's not working as expected mainly because loading templates could be asynchronous, and that does not work well with the internal call to .send()
, as there is no way to await that.
It following should work with any template engine.
What we need as next steps is a proposal to implement an API that could be awaited upon, and then an implementation.
Before you submit an issue we recommend you drop into the Gitter community or Fastify Help and ask any questions you have or mention any problems you've had getting started with Fastify.
Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the missing discussion
label.
Make the data-parameter of .view(page, data)
for all template-engines optional.
I already created the corresponding PR #131.
This seems to catch up to the PR #52.
I use the view-function often with implicitly provided data via the defaultContext
. Currently this efforts in any case (than the pure ejs
-template-handler) that an empty objeckt ({}
) must be provided.
Since the pure ejs
-view-function treats the data-parameter already as optional, i expected it to be optional for the other template-engines, too.
fastify.register(require('../index'), {
engine: {
'ejs-mate': require('ejs-mate')
},
defaultContext: { text: 'text' },
templates: 'templates'
})
fastify.get('/', (req, reply) => {
reply.view('index.ejs', {})
})
fastify.register(require('../index'), {
engine: {
'ejs-mate': require('ejs-mate')
},
defaultContext: { text: 'text' },
templates: 'templates'
})
fastify.get('/', (req, reply) => {
reply.view('index.ejs')
})
Handlebars engine very commonly uses the extension ".hbs", although point-of-view is not configure for it.
The ejs link in your README is pointing to a spam site. I believe the correct URL is now https://ejs.co/
layout
is optional for some template engines.
So it's supposed to be under options
as others.
If there are no objections I'll take a stab at a PR.
βοΈ Greenkeeperβs updated Terms of Service will come into effect on April 6th, 2018.
Branch | Build failing π¨ |
---|---|
Dependency | nunjucks |
Current Version | 3.1.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
nunjucks is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 7 commits.
6f3e4a3
v3.1.1
eed7b2d
Fix bug that broke template caching. fixes #1074
db8e3c3
Fix error when running npm install nunjucks --no-bin-links
2c97201
try/catch require of chokidar to make it truly optional
a65d3b8
bower forbids minified js in the main property
2c98065
Add nunjucks folder to bower.json ignore
470181d
Prepare for next release
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
11.10.4
to 11.10.5
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Before you submit an issue we recommend you drop into the Gitter community or Fastify Help and ask any questions you have or mention any problems you've had getting started with Fastify.
Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the missing discussion
label.
A clear and concise description of what the bug is.
this.header return undefined
so "message": "Cannot read property 'send' of undefined"
change to:
this.header('Content-Type', 'text/html; charset=' + charset)
this.send(html)
Steps to reproduce the behavior:
Paste your code here:
this.header('Content-Type', 'text/html; charset=' + charset)
this.send(html)
3.1.7
to 3.2.0
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
nunjucks is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
NodeResolveLoader
, a Loader that loads templates using node's require.resolve
. Fixes #1175.Environment
instances, to allow runtime dependency tracking. Fixes #1153.The new version differs by 11 commits.
ff5571c
Release v3.2.0
f997a52
Add NodeResolveLoader
34b0a26
Fix syntax typos in CONTRIBUTING.md
55e0b7a
Set dash as joiner element
c99154e
Update faq.md
1338712
Emit 'load' events on Loader and Environment instances
057e7b3
Add test for line/column info in user-function exception
bcf38f3
Emit line and column info for functions
fbddcd5
lexer more accurately tracks token line and column information
889ef80
Add nodejs versions 10 and 11 to CI, remove 6 and 9
b828158
Fix documentation typo
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Hi all,
I just see that a new release of Nunjucks is available, so could be good to use it.
See here.
And update other dependencies too, but keep Fastify to pre-1.0.x (0.43.0), ok ?
{
engine: {
njk: require('nunjucks')
}
}
Not working.
Branch | Build failing π¨ |
---|---|
Dependency | fastify |
Current Version | 1.11.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
fastify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
Internals
Documentation
The new version differs by 13 commits.
4e047a8
Bumped v1.11.2
c40ea62
Add trivikr@ to the collaborators list (#1139)
0a27c92
Correct typos in Github Issue Template (#1140)
5b18645
Updated ecosystem doc (#1137)
0a874b9
Handle promises in the error handler with the same logic of normal handlers (#1134)
cce1a85
Rename ContentTypeParser (#1123)
6d302a5
Add test for error fixed in mcollina/avvio#74 (#1132)
60b85e7
Update Validation-and-Serialization.md (#1124)
d6982ea
Remove/Merge redundant decorate functions (#1120)
baeebef
Updated standard to v12. (#1121)
7c8401d
Update ContentTypeParser.js (#1122)
a14397d
ecosystem in alphabetical order
8a0c618
Update Ecosystem.md (#1125)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
When referring to the wrong variable, express gets an exception rather than hangs, but when fastify, it causes the entire program to die.
Hi all,
for consistency with Fastify (and with some other core plugins) I think could be useful to change the devDependency from 'request' to latest 'simple-get', and maybe update all other dependencies ...
What do you think ?
If accepted, I'll do a PR with changes (even related tests of course).
Thanks, Sandro
The actual options for getHeader
is not compliant to the fastify codebase that support the chaining-call:
ex: this.header('Content-Type', 'text/html; charset=' + charset).send(html)
It would be awsome if @momofan or @florianb could work on this πͺ
Mode info on how to implement this improvement:
Lines 52 to 53 in b7345f0
They are replicating the core Reply
methods and should behave accordingly. In fact, I'm not sure why the view
decoration is on the server object. Views should be rendered in the context of a request, and in particular the context of sending a reply. So I would think the view
decoration should be fastify.decorateReply('view', function () {})
. Which would mean the following would be an outline of a solution:
fastify.decorateReply('view', function () {
// other details omitted
renderer.apply({getHeader, header}, args)
function getHeader (key) {
return this.getHeader(key)
}
function header (key, val) {
return this.header(key, val)
}
})
Branch | Build failing π¨ |
---|---|
Dependency | fastify |
Current Version | 1.10.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
fastify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
Features
Internals
Documentation
The new version differs by 11 commits.
c62ace8
Bumped v1.11.0
acf3950
Override address in listen instead of listenPromise (#1102)
e6bca66
Move Server-Methods into Factory (#1101)
ba9a629
Update Validation-and-Serialization.md (#1094)
e77cae9
Add test for trust proxy with function (#1098)
6bce249
Ensure that error-in-post test is run (#1096)
3895a75
Rename and call unknown method tests from http2 (#1095)
1f750e6
Ignore pino in greenkeeper, it's a semver-major change
28436d1
chore(package): update concurrently to version 4.0.0 (#1091)
a258482
Update TypeScript to 3.0.1 (#1092)
50bcf6b
Added pluginTimeout option. (#1088)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
App.register(require('point-of-view'), { engine: { pug: require('pug') }, options:{}, templates: 'templates' })
I got :
Error: the "filename" option is required to use includes and extends with "relative" paths
in the file :
extends ./layout.pug block content p hola
How I pass filename to options object inside the configuration ?
Branch | Build failing π¨ |
---|---|
Dependency | marko |
Current Version | 4.3.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As marko is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
hello, i tried to include my header and footer but it doesn't works
how can i include it in my file
i tried to import like this
<% include views/admin/header %>
and get error like this
{"statusCode":500,"error":"Internal Server Error","message":"Could not find the include file "views/admin/header""}
Why is the data argument required? In my application I have several templates who don't need any variables for example.
hey there- I recently started playing around with Fastify, so excuse me if i just missed something before making this issue.
I have a use case where i want to output xml (rss feed). The rss template is actually in a pug template. This is just because it's easier to work with.
So the flow is-- I go get my data, set the content-type with reply.header('Content-Type', 'text/xml');
then call view()
with the template and my data.
The expectation is that i'll end up with an xml response. What actually happens is that the content-type gets overridden when you call view()
with a template-
https://github.com/fastify/point-of-view/blob/master/index.js#L53
I'm curious if there's a specific reason behind this? Or if it's acceptable to check for a content-type defined, and not assign text/html
if there is one?
Branch | Build failing π¨ |
---|---|
Dependency | marko |
Current Version | 4.11.5 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
marko is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 8 commits.
b5f5f66
update changelog
c6829e1
4.12.0
8bcb848
enable style arrays (#1082)
280f734
fixes #1075 - cannot compile dynamic tag at root with user key (#1081)
f48e22c
Fixes #1078 - don't mutate spread attributes (#1080)
f5ebda8
Tag params (#1076)
63b0aeb
dynamic tag fixes
2ec6695
update changelog
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Error: fastify-plugin - expected '^1.1.0' fastify version, '2.0.0' is installed
If/when someone have time,
π π π§
βοΈ Greenkeeperβs updated Terms of Service will come into effect on April 6th, 2018.
Branch | Build failing π¨ |
---|---|
Dependency | request |
Current Version | 2.83.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
request is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 6 commits.
d77c839
Update changelog
4b46a13
2.84.0
0b807c6
Merge pull request #2793 from dvishniakov/2792-oauth_body_hash
cfd2307
Update hawk to 7.0.7 (#2880)
efeaf00
Fixed calculation of oauth_body_hash, issue #2792
253c5e5
2.83.1
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Is it possible to build in support for twig.js?
link: https://github.com/twigjs/twig.js
4.14.22
to 4.14.23
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
marko is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 4 commits.
a5d80a4
4.14.23
2a0ecec
Update changelog
6ed4e9d
Improve optimization for nested tags wrapped in an if statement (#1249)
ecae71c
Fix 'marko is using deprecated features' message (#1250)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If youβre interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didnβt already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didnβt touch job or matrix configurations because these tend to be quite specific and complex, and itβs difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what youβre doing it may require additional work or may not be applicable at all. Weβre also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, Iβm a humble robot and wonβt feel rejected π€
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
I'm working on transitioning an Express app to Fastify. Here's my server code:
const fastify = require("fastify")();
const handlebars = require("handlebars");
const log = console.log; // eslint-disable-line
fastify.register(require("point-of-view"), {
engine: {
handlebars: handlebars
},
templates: `${__dirname}/views`
});
fastify.get("/", async (request, reply) => {
reply.view("/home.html", { body: `<p>Cool</p>` });
});
const start = async () => {
try {
await fastify.listen(process.env.PORT || 8080, process.env.IP || "0.0.0.0");
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
log(`Server listening on ${fastify.server.address().port}`);
}
start();
This is in my home.html
template:
<!DOCTYPE html>
<html lang="en">
{{> views/head }}
<body class="home">
{{> views/navigation }}
<main>
{{{ body }}}
</main>
{{> views/footer }}
</body>
</html>
The error message I get is "The partial views/head could not be found". The thing is though, views/head.html
exists. Nothing I have tried is working.
Iβve made a reduced test case at tigt/streaming-html-minifier-reduced-test-case.
If you comment out useHtmlMinifier
and comment in useHtmlMinifyStream
, the rendered HTML is not minified. However, for the reverse, it is. Am I doing something wrong?
i can only return json if i'm calling a promise inside the router, how do i do something like this?
i am creating amp pages so i cannot consume api from frontend, i'm using point-of-view to render the data on the layout.
fastify.get('*', function (req, res) {
return new Promise(function (resolve) {
axios.get(`/contents`).then(({data}) => {
// res.view('blog/content', {
// data: data
// });
resolve() //what to resolve here?
}, err => {
res.code(404)
resolve(res) //
})
})
});
Hi all,
I just see that if I don't set in explicit way reply encoding, Firefox will complaint on missing encoding.
So for reply.view I need to do (anytime) something like:
reply.type('text/html; charset=utf-8').view('index', data)
What do you think on adding that encoding as default for views (could be a good default) ?
Or check the encoding of related view (file) ... but this could be too much and alittle more expensive in performances.
What do you think ?
Thanks,
Sandro
Calling reply.view
in an async
handler function logs an error:
{"level":50,"time":1541536966444,"msg":"Promise may not be fulfilled with 'undefined' when statusCode is not 204","pid":17183,"hostname":"ip-10-10-10-218.ec2.internal","reqId":1,"err":{"type":"Error","message":"Promise may not be fulfilled with 'undefined' when statusCode is not 204","stack":"Error: Promise may not be fulfilled with 'undefined' when statusCode is not 204\n at /home/steve/ff-pov/node_modules/fastify/lib/wrapThenable.js:18:34"},"v":1}
The rendered html will actually arrive at the browser, but the above message will be logged to console.
Here is example server:
const fastify = require("fastify")({
logger: true
});
fastify.register(require("point-of-view"), {
engine: {
nunjucks: require("nunjucks")
}
});
async function something() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(new Date());
}, 1000);
});
}
fastify.get("/", async (req, reply) => {
const t = await something();
reply.view("/home.html", { text: t });
});
fastify.listen(3000, err => {
if (err) throw err;
console.log(`server listening on ${fastify.server.address().port}`);
});
Is there a better way to do this?
I separate and registe rendering config in other file.
// marko_conf.js
const path = require("path");
module.exports = async (fastify, opts) => {
fastify.register(require("point-of-view"), {
engine: {
marko: require("marko"),
},
includeViewExtension: false,
templates: path.join(__dirname, "./templates")
});
};
// app.js
const fastify = require("fastify")();
fastify.register(require("./marko_conf.js"));
fastify.get("/", (req, reply) => {
reply.view("index.marko", { text: "hi" });
});
fastify.listen(3000);
/home/jimmy/Desktop/test/app.js:7
reply.view("index.marko", { text: "hi" });
^
TypeError: reply.view is not a function
at Object.fastify.get (/home/jimmy/Desktop/test/app.js:7:8)
at preHandlerCallback (/home/jimmy/Desktop/test/node_modules/fastify/lib/handleRequest.js:88:30)
at handler (/home/jimmy/Desktop/test/node_modules/fastify/lib/handleRequest.js:72:5)
at handleRequest (/home/jimmy/Desktop/test/node_modules/fastify/lib/handleRequest.js:22:5)
at onRunMiddlewares (/home/jimmy/Desktop/test/node_modules/fastify/fastify.js:346:5)
at middlewareCallback (/home/jimmy/Desktop/test/node_modules/fastify/fastify.js:334:7)
at Object.routeHandler [as handler] (/home/jimmy/Desktop/test/node_modules/fastify/fastify.js:224:7)
at Router.lookup (/home/jimmy/Desktop/test/node_modules/find-my-way/index.js:265:17)
at Server.emit (events.js:180:13)
at parserOnIncoming (_http_server.js:642:12)
but, if I regist in the same file that will work
13.7.6
to 13.7.7
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
12.4.0
to 12.4.1
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
tap is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 7 commits.
c17e6db
12.4.1
88eb85b
Ignore timers in _getActiveHandles reporting
58699d7
remove unused js-yaml from lib/tap.js
4621be8
node 11 no longer blocks process.reallyExit
74e4671
Add node 11 to travis
b074a1a
Don't use bluebird
e8fb7df
update nyc to v13
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
Hi guys,
Have any of you got troubles with including other EJS components within an EJS file? I'm getting following error "Error: Could not find include include file.".
Example:
<% include header %> within the "index.ejs" file.
It works in Express, so maybe I just can't find the relative path somehow. All my ejs files is located in the same folder, so shouldn't be an issue.
Thanks.
Is multiple templates directory like the one below supported? Since some of the template engines supported allows extension of templates (template inheritance) from other templates (e.g. nunjucks
).
root
ββββmodules
β β ββββhome
β β β β index.js
β β β ββββtemplates
β β β β ββββhome
β β β β β β home-template1.html (inherits from base.html)
β β β β β β home-template2.html (inherits from base.html)
β β ββββabout
β β β β index.js
β β β ββββtemplates
β β β β ββββabout
β β β β β β home-template1.html (inherits from base.html)
β β β β β β home-template2.html (inherits from base.html)
ββββtemplates
β β base.html
Master
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title><%= title ? title : '' %> - Backbeard</title>
</head>
<body>
<% include ../inc/navbar %>
<div class="container">
<%- body -%>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
Index
<% layout('layouts/master') -%>
<h1>I am the template</h1>
Route
fastify.get('/', async (request, reply) => {
return await fastify.view('/index.ejs', { title: 'text' })
})
I also tried options like reply.view
with and without async. I tried everything. I do not know what I do wrong
Hello,
I just want to render a page with variables. Passing getting the variables and passing them with res.send works fine but if I use res.view I get an error that the promise is not fulfilled. I am pretty new to Javascript and especially to async functions.
My code looks as follow:
exports.show = async (req, res) => {
try {
const [var1, var2] = await Promise.all([
getUser(id),
getInfo(id)
])
res.view("index.pug", {var1: var1, var2: var2})
} catch {
if (err) throw err
}
}
What am I doing wrong?
Thanks
4.14.5
to 4.14.6
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
marko is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 4 commits.
00ae73e
4.14.6
e8e4a41
Update changelog, remove old roadmap
3f1d742
Remove deprecations already moved to the migrate stage (#1196)
0fdc5a2
Whitelist files published to npm (#1197)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
defaultContext
property is missing in PointOfViewOptions
interface in TypeScript declaration file index.d.ts although the property is described in the README
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.