Variables

Every template that is rendered has access to variables when it is rendered. The following describes what variables are accessible from a template file. They are all accessible within a template via {{site.title}} or {{theme.css}}, etc.

site

This contains all values that are defined in your reptar.config.js's site object. Anything you put there will be accessible from every file that is rendered.

An example site object:

{
  "site": {
    "title": "My Name",
    "email": "my@email.com",
    "description": "Personal blog.\n",
    "url": "http://example.com/"
  }
}

site.data

If you have any data files they will be accessible here. Read more about how to use data files.

{
  "site": {
    "data": {}
  }
}

reptar

This contains meta information about your Reptar installation.

{
  "reptar": {
    "version": "2.0.0",
    "time": "2015-11-28T15:30:33-05:00"
  }
}

collections

This is an object whose keys reflect every Collection that you have defined in your reptar.config.js, and every value is also an object.

The keys on a collection are files and pages. Both are arrays which contain a File data object and a Pagination data object respectively.

For example the default post collection looks like this:

{
  "collections": {
    "post": {
      "files": [
        // File data objects
      ],
      "pages": [
        // Pagination data objects.
      ]
    }
  }
}

File data object

These are found within a non-static collection. They include all Frontmatter defined data in the object as well as two additional fields, content which contains the non-Frontmatter data, and url which can either be defined in the file or is derived from from the File's Collection's permalink value.

An example File data object:

{
  "file": {
    "title": "Example post",
    "date": "2015-08-15T02:17:07.184Z",
    "content": "<p>Contents of file.</p>\n",
    "url": "/example-post/"
  }
}

Pagination data object

If a Collection has defined pagination variables then it will contain a pages array full of Pagination data objects. This allows for easy pagination of Collection Files. Each Pagination data object contains information about the page as well as containing the files that belong in that page, so you can render a list of those files.

An example Pagination data object:

{
  "pagination": {
    "page": 1,
    "files": [{
      // File data objects
    }],
    "total_pages": 67,
    "per_page": 6,
    "total": 399,
    "url": "/",
    "next": 2,
    "next_link": "/page/2/"
  }
}