Matt Hinchliffe edited this page Sep 26, 2013 · 3 revisions

Data can be provided globally to templates (layouts, partials and pages) via data files. Data files can be provided in JSON or YAML formats or as a JavaScript module. Robot is able to scan nested directories and will only attempt to register files with the following file extensions:- .json, .yml, .yaml and .js.

Please note that currently directory structure has no affect and all data is available at a single level.



    "firstName": "John",
    "lastName": "Doe",
    "age": 28,
    "email": ""


module.exports.pets = {
    rover: {
        age: 7,
        type: "dog",
        gender: "male"
    mittens: {
        age: 3,
        type: "rabbit",
        gender: "female"

module.exports.typesOfPets = function() {
    var uniqueTypes = [];

    for (var pet in this.pets) {
        if (this.pets.hasOwnProperty(pet) && uniqueTypes.indexOf(this.pets[pet]['type']) === -1) {

    return uniqueTypes;

Using Robot: Next: Partials