Render Jade as part of Angular
I am learning MEAN concepts with this video course by Joe Eames. This course is interesting in that it teaches how to use JADE templates as partials rather than HTML.
\bin
\node_modules
\public
\app
\main
someCntr.js
otherCntr.js
main.js
\server
\views
\partials
main.jade
featured-courses.jade
new-courses.jade
And all went well until he moved these jade patterns from \views\includes
before \public\app\main
and \public\app\courses
in his Express 3.4. This trick doesn't work in my Express 4
its server.js file before
app.set('views', path.join(__dirname, '/server/views'));
app.set('view engine', 'jade');
app.get('/partials/:partialPath', function(req, res) {
res.render('partials/' + req.params.partialPath);
});
and after moving
app.set('views', path.join(__dirname, '/server/views'));
app.set('view engine', 'jade');
app.get('/partials/*', function(req, res) {
res.render('public/app/' + req.params);
});
+3
source to share
2 answers
I am also studying this course and I have the same problem ... The solution is to use req.params [0]. In the server.js file, the path to the partial views looks like this:
insted
app.get('/partials/*', function(req, res) {
res.render('public/app/' + req.params);
});
records:
app.get('/partials/*', function(req, res) {
res.render('../../public/app/' + req.params[0]);
});
0
source to share