Created
February 22, 2018 20:50
-
-
Save kenichi/eb2392ada97211906d6a5c5b9ef5b011 to your computer and use it in GitHub Desktop.
express serve partials from outside tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| const app = require('express')(); | |
| const viewsDir = __dirname + '/views'; | |
| const otherDir = __dirname + '/../ax'; | |
| const hbs = require('express-handlebars').create({ | |
| defaultLayout: 'main', | |
| layoutsDir: viewsDir + '/layouts', | |
| partialsDir: [ | |
| viewsDir + '/partials', | |
| otherDir | |
| ], | |
| extname: '.hbs' | |
| }); | |
| app.engine('.hbs', hbs.engine); | |
| app.set('view engine', '.hbs'); | |
| app.set('views', viewsDir); | |
| app.get('/', function (req, res) { | |
| res.render('index'); | |
| }); | |
| app.listen(3000, function () { | |
| console.log('listening on: 3000'); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
../ax/header.hbsis outside the tree,views/index.hbshas:in it and it renders properly.