# Template Data & Helpers

### Standard Template Data <a href="#standard-template-data" id="standard-template-data"></a>

* `site` — an object of several site-specific properties, contains:
  * `date` — a JavaScript date object for the time that the website was last generated
* `document` — a JavaScript Object containing the serialised values of our `documentModel` (e.g., `documentModel.toJSON()`)
* `req` — dynamic documents will also have this available to the, it is a reference to the current request object created by the [ExpressJS](http://expressjs.com/) framework
* `content` — when rendering layouts the `content` template data variable contains the contents of the rendered child content to be injected into the current layout for rendering

### Standard Template Helpers <a href="#standard-template-helpers" id="standard-template-helpers"></a>

* `include(relativePath)` return the content of another file at the given path
* `getEnvironment()` — a string of the current environment(s) we are running under
* `getEnvironments()` — an array of the current environments we are running under
* `referencesOthers()` — when called, will set the document's `referenceOthers` [meta data](/core/meta-data.md) property to `true`
* `getDocument()` — a reference to the current document we are rendering, documents are defined by the [Document Class](https://github.com/bevry/docpad/blob/master/src/lib/models/document.coffee) which extends the [File Class](https://github.com/bevry/docpad/blob/master/src/lib/models/file.coffee) which extends a [Backbone Model](http://backbonejs.org/#Model)
* `getBlock(blockName)` — valid block names are:
  * `scripts` — a collection of scripts to be outputted
  * `styles` — a collection of styles to be outputted
  * `meta` — a collection of meta to be outputted
* `getPath(path,parentPath)` get a path with respect to the path of the current document

#### Querying <a href="#querying" id="querying"></a>

* `getDatabase()` — a [Query-Engine](https://github.com/bevry/query-engine) collection of all our documents
* `getCollection(collectionName)` — a [Query-Engine](https://github.com/bevry/query-engine) collection of a particular sub collection, built in collections are:
  * `documents` — for all documents
  * `files` — for all files
  * `layouts` — for all files
  * `html` — for all documents and files that result in an HTML file
  * `stylesheet` — for all stylesheet files (includes stylesheet pre-processor files)
* `getFiles(query, sorting, paging)` get all files that match the arguments, caches the result collection
* `getFile(query, sorting, paging)` get a single file that matches the arguments
* `getFilesAtPath(path, sorting, paging)` get a file at the given path, path is processed through `getPath`
* `getFileAtPath(path, sorting, paging)` get a single file at the given path, path is processed through `getPath`
* `getFileById(id, sorting, paging)` get a single file that has the specified id


---

# 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://docpad.bevry.me/core/template-data.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.
