A
A
Alexey Yakovlev2020-09-01 16:23:05
JavaScript
Alexey Yakovlev, 2020-09-01 16:23:05

HTML files are not created from hbs, what should I do?

gulp(hbs):

const handlebars = require('gulp-compile-handlebars');

gulp.task('default', function () {
    const options = {
        ignorePartials: true,
        batch : ['src/views/partials'],
        helpers : {
            capitals : function(str){
                return str.toUpperCase();
            }
        }
    }
     
    return gulp.src('src/views/*.hbs')
        .pipe(handlebars(options))
        .pipe(gulp.dest('dist/'));
});


server(hbs):
const exphbs = require('express-handlebars');
const homeRoutes = require('./src/routes/home.js');
const app = express();
const hbs = exphbs.create({
    defaultLayout: 'main',
    extname: 'hbs'
});

app.use('/', homeRoutes);

app.engine('hbs', hbs.engine);
app.set('view engine', 'hbs');
app.set('views', 'views');


cannot get / error even though everything should work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eifory, 2020-09-08
@eifory

maybe 'views' and 'src/views' are not the same?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question