Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.14 KB

output-formats.md

File metadata and controls

61 lines (51 loc) · 1.14 KB

HAG - Output formats

HAG supports three types of output; text, JSON, and image (PNG).

Text Renderer

HAG can generate any type of text template (assumes utf-8).

{
  "asset": "example-text-asset.md",
  "template": "/example-text-template.hbs",
  "renderer": {
    "type": "text"
  },
  "data": {
    "$ref": "/data/example-data.json"
  }
}

JSON Renderer

HAG makes a special case for JSON data so that it can be formatted nicely. Note: no template is required for the JSON renderer.

{
  "asset": "example-json-asset.json",
  "renderer": {
    "type": "json",
    "spacing": "  "
  },
  "data": {
    "expected-output": {
      "$ref": "/data/example-data.json"
    }
  }
}

Webshot Image Renderer (PNG)

HAG is primarily aimed at generating using images from HTML/CSS templates. It uses the webshot API which in turn runs on top of phantom.

Example using webshot render

{
  "asset": "example-image-asset.png",
  "template": "/example-html-template.hbs",
  "renderer": {
    "type": "webshot",
    "size": {
      "width": 640,
      "height": 960
    }
  },
  "data": {
    "$ref": "/data/example-data.json"
  }
}