<commit_before>## Views

hapi has extensive support for template rendering, including the ability to load and leverage multiple templating engines, partials, helpers (functions used in templates to manipulate data), and layouts.

## Configuring the server

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:

```javascript
var Path = require('path');
var Hapi = require('hapi');

var server = new Hapi.Server();
server.views({
    engines: {
        html: require('handlebars')
    },
    path: Path.join(__dirname, 'templates')
});

```

We're doing several things here.

First, we register the `handlebars` module as the engine responsible for rendering templates with an extension of `.html`.

Second, we tell the server that our templates are located in the `templates` directory within the current path. By default, hapi will look for templates in the current working directory. You can set the path parameter to wherever your templates are located.

### View options

There are many options available to the views engine in hapi. Full documentation can be found in the [API reference](/api/#server-options), but we'll go over some of them here as well.

Note that all options may be set either globally, which configures them for all registered engines, or local to one specific engine, for example:

```javascript
server.views({
    engines: {
        'html': {
            module: require('handlebars'),
            compileMode: 'sync' // engine specific
        }
    },
    compileMode: 'async' // global setting
});
```<commit_msg>Update Views tutorial to reflect v9.0.0 changes<commit_after>## Views

hapi has extensive support for template rendering, including the ability to load and leverage multiple templating engines, partials, helpers (functions used in templates to manipulate data), and layouts.

## Configuring the server

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:

```javascript
var Path = require('path');
var Hapi = require('hapi');

var server = new Hapi.Server();

server.register(require('vision'), function (err) {
    if (err) {
        console.log("Failed to load vision.");
    }
});

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

```

We're doing several things here.

First, we load the [`vision`](https://github.com/hapijs/vision) module as a plugin. It adds template rendering support to hapi. Since [`vision`](https://github.com/hapijs/vision) is no longer included with hapi, you may need to install it.

Second, we register the `handlebars` module as the engine responsible for rendering templates with an extension of `.html`.

Second, we tell the server that our templates are located in the `templates` directory within the current path. By default, hapi will look for templates in the current working directory. You can set the path parameter to wherever your templates are located.

### View options

There are many options available to the views engine in hapi. Full documentation can be found in the [API reference](/api/#server-options), but we'll go over some of them here as well.

Note that all options may be set either globally, which configures them for all registered engines, or local to one specific engine, for example:

```javascript
server.views({
    engines: {
        'html': {
            module: require('handlebars'),
            compileMode: 'sync' // engine specific
        }
    },
    compileMode: 'async' // global setting
});
```
{'fraction_non_alphanumeric': 0.08935361216730038, 'fraction_numerical': 0.0008147745790331341, 'mean_word_length': 3.8652575957727873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6777533', 'n_tokens_mistral': 935, 'n_tokens_neox': 921, 'n_words': 469}