-
Notifications
You must be signed in to change notification settings - Fork 92
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
callback function required #6
Comments
I'll take a look. But remember. You need to have those component files in the right place. You can't just add components in that don't exist. So the library is going to expect these to exist. app/layout.vue That's what it's going to expect looking at your config. If your stuck go have a look at the example project https://github.com/danmademe/express-vue-example I'll come back and look at this in a few hours. |
Since the library is written as an ES6 module, app.engine('vue', expressVue.default) // and not just expressVue When you pass in |
Looks like I forgot that the new babel doesn't include the default plugin anymore. I'll add it later and rebuild. |
If this solves the issue I'll close it. Thanks @just-nobody |
OK I've fixed the .defaults issue in the latest release |
@jerome724 can you verify this and close the issue |
Now i'm getting
directory structure is the one from the example. |
@jerome724 what version of node are you using? |
I'm on v7.0.0 |
New version pushed to NPM @3.0.2 |
Issue was fs.readFile outputs a buffer, so instead of doing buffer.toString() i changed the way FS works by changing the output to UTF-8. |
const express = require('express');
const expressVue = require('express-vue');
const app = express();
app.set('views', './views');
app.set('vue', {
rootPath: './',
layoutsDir: 'views/layouts',
components: 'views/components',
defaultLayout: 'main'
});
app.engine('vue', expressVue);
app.set('view engine', 'vue');
app.get('/', (req, res) => {
res.render('index', {
vue: {
meta: {
title: 'www.jerome724.com'
}
}
});
});
app.listen(8080); Is with this something wrong? Because i'm getting now
|
This is the function its calling function htmlParser(body, minify) {
let bodyString = body.match(htmlRegex)[0];
........
return bodyString;
} The error is that the body argument is undefined/null, it's getting called from the component parser const body = htmlParser(content, true); (the true is to minimise the output or not) it means that the output from fs.readFile isn't being passed into it... which tells me it's unable to read the Looking at your setup.. index.vue is in so if this was run from say, the root, so your structure was like
So if you ran |
remember if the component you're trying to access is in a sub directory of the components directory... so something like you'd have to change the |
i made a test version https://github.com/danmademe/express-vue-example-basic
|
the big difference? app.set('vue', {
rootPath: __dirname + '/views/',
layoutsDir: 'layouts/',
components: 'components/',
defaultLayout: 'main'
});
......
app.get('/', (req, res) => {
res.render('components/index', {
vue: {
meta: {
title: 'www.jerome724.com'
}
}
});
}); the rootpath was not set to where the root of the views were.. I will update this logic to fit better. the second part was that when res.render is called, it is looking for a file relative to the rootPath... this logic won't be changed, because the The way to think of it is like this You have a Layout, that's your main file.. then what you set in res.render.. that's your route, or what i call your COMPONENT... if that component has components .. its what I call a "SUBCOMPONENT", which gets built into a vue component and placed in the route's components section... |
A better way of doing this... is like this
So when you do Separating the routes from components, so its a cleaner directory structure... the idea of components is the tiny reusable subcomponents that you use in your routes :) |
@jerome724 did this solve the issue? |
Feature/cache script
Hey!
I'm getting this error:
My code is the example code
Why does express is telling me there is no callback?
The text was updated successfully, but these errors were encountered: