Template Data & Helpers

Standard Template Data

  • 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 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

  • 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 property to true

  • getDocument() — a reference to the current document we are rendering, documents are defined by the Document Class which extends the File Class which extends a Backbone 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


  • getDatabase() — a Query-Engine collection of all our documents

  • getCollection(collectionName) — a 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

Last updated