Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 917 Bytes

File metadata and controls

34 lines (25 loc) · 917 Bytes

Templating with Helper Functions


alt text

What are helper functions ?

functions used in templates to manipulate data

How they can be implemeted in handlebars ?

To get started with views, first we have to configure at least one templating engine on the server. This is done by using the server.views method:
```
'use strict';

const Path = require('path');
const Hapi = require('hapi');
const Hoek = require('hoek');

const server = new Hapi.Server();

server.register(require('vision'), (err) => {

    Hoek.assert(!err, err);

    server.views({
        engines: {
            html: require('handlebars')
        },
        relativeTo: __dirname,
        path: 'templates'
    });
});
```