koajs / koa-hbs

Handlebars templates for Koa.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to do render theme view?

einsqing opened this issue · comments

how to do render theme view?

Not quite sure what you're asking there. Please rephrase and elaborate.

like this

router.use('/home', home.routes(), function *(next) {
    hbs.configure({
        viewPath: path.resolve(__dirname, path.normalize('./../view/home')),
        layoutsPath: path.resolve(__dirname, path.normalize('./../view/home/layout')),
        partialsPath: path.resolve(__dirname, path.normalize('./../view/home/partial')),
        defaultLayout: layout,
        extname: '.html',
        disableCache: true
    });

    yield next;
});
router.use('/admin', admin.routes(), function *(next) {
    hbs.configure({
        viewPath: path.resolve(__dirname, path.normalize('./../view/admin')),
        layoutsPath: path.resolve(__dirname, path.normalize('./../view/admin')),
        partialsPath: path.resolve(__dirname, path.normalize('./../view/admin')),
        defaultLayout: layout,
        extname: '.html',
        disableCache: true
    });

    yield next;
});

I want to render diffrent theme and like this is wrong.so what do i do?

All layouts have to be in the same directory. You can layer the directory, but at this time they all have to be in one. (partialsPath is the only path option that supports an array of paths) Then, to use different layouts., reference the README:

In addition to, or alternatively, you may specify a layout to render a template into. Simply specify {{!< layoutName }} somewhere in your template. koa-hbs will load your layout from layoutsPath if defined, or from viewPath otherwise.