Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render Jade like an Angular partial

I study the MEAN conceptions by this video course by Joe Eames. This course interesting because teach how to use JADE templates as partials instead of 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 was going well until he moved this jade templates from \views\includes to \public\app\main and \public\app\courses in his Express 3.4. This trick does not work in my Express 4

his 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);
});
like image 267
khex Avatar asked Jul 16 '26 09:07

khex


1 Answers

You have to update jade to it's latest version:

http://expressjs.com/guide/migrating-4.html

like image 141
Vladimir Trifonov Avatar answered Jul 19 '26 01:07

Vladimir Trifonov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!