Skip to content

specifying a custom template #135

Description

@punkish

I am experimenting with the latest version of hapi-swaggered + hapi-swaggered-ui. So far so good. However, I would like to use my own handlebars template for the docs as well as to match the look and feel of the rest of the project. I created my own docs.hbs content and layout following templates/indexhbs, but of course, I can't figure out how to tell the plugin to use them. Is there an option setting where I can specify a different template?

Plus, (and this is not a huge setback but), I'd like to specify .html as the extension for my templates. I already use the following invocation

server.views({
        engines: {
            html: require('handlebars')
        },
        relativeTo: __dirname,
        path: './views',
        layoutPath: './views/layouts',
        partialsPath: './views/partials',
        layout: 'main',
        isCached: false
    });

Of course, I can add hbs: require('handlebars') to the engines section above, and that seems to work, but it would be simpler if all my templates could have the same extension.

Update: So I was able to do this by adding the following five settings to the plugin options

const hapiSwaggeredUiOpts = {
    
    relativeTo: __dirname,
    contentTemplate: 'docs',
    layoutTemplate: 'docs',
    templates: './views',
    layoutPath: './views/layouts',
    partialsPath: './views/partials',}

and creating my custom templates in the above specified directories. Of course, I had update lib/index.js to accommodate the above settings.

I am sure a zillion things can go wrong with what I did, but it seems to work for me without any problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions