Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specifying a custom template #135

Open
punkish opened this issue Feb 21, 2019 · 0 comments
Open

specifying a custom template #135

punkish opened this issue Feb 21, 2019 · 0 comments

Comments

@punkish
Copy link

punkish commented Feb 21, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant