# View

## Description

The `view` function allows you to render any of the view files that you place within the `/views` directory. When you call `view`, Pode will automatically look within this directory.

Pode uses a View Engine to either render HTML, Pode, or other types. Default is HTML, and you can change it to Pode by using the [`engine`](https://pode.gitbook.io/docs/functions/engine) function.

## Examples

1. The following example will render the `index.html` view when you navigate to `http://localhost:8080`:

   ```
    Server {
        listen *:8080 http

        route get '/' {
            view 'index'
        }
    }
   ```
2. The following example will render the `index.pode` view when you navigate to `http://localhost:8080`:

   ```
    Server {
        listen *:8080 http
        engine pode

        route get '/' {
            view 'index'
        }
    }
   ```
3. The following example will render the `index.pode` view when you navigate to `http://localhost:8080`, it will also supply dynamic data - in this case, the current date:

   > The dynamic data can be used in your pode view via `$($data.date)`

   ```
    Server {
        listen *:8080 http
        engine pode

        route get '/' {
            view 'index' -d @{ 'date' = [DateTime]::Now }
        }
    }
   ```

## Parameters

| Name | Type      | Required | Description                                                                                          | Default |
| ---- | --------- | -------- | ---------------------------------------------------------------------------------------------------- | ------- |
| Path | string    | true     | The path to the view to render, relative to your `/views` directory                                  | null    |
| data | hashtable | false    | A hashtable of dynamic data that will be supplied to `.pode`, and other third-party template engines | `@{}`   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pode.gitbook.io/docs/functions/view.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
