Skip to content

Available variable in custom templates

Alexander Slansky edited this page Jun 7, 2015 · 4 revisions

Variables in custom templates

  • layouts - an array of layout objects <Array>
    • name - name of the layout <Sring>
    • classname - classname of layout <Sring>
    • layout - object with the layout data
      • height - height of the layout <Number>
      • width - width of the layout <Number>
      • items - array of objects with information about the tiles <Array>
        • height - height of the tile <Number>
        • width - width of the tile <Number>
        • meta - object of meta information of the tile
          • base - base path of the tile image <String>
          • contents - contents of the tile image <Buffer>
          • fileName - file name of the tile image <String>
          • height: - height of the tile image <Number>
          • name: - name of the tile image <String>
          • path: - local path to the tile image <String>
          • type: - type of the tile image (e.g png) <String>
          • width: - width of the tile image <Number>
        • x - X position of the tile <Number>
        • y - Y position of the tile <Number>
    • sprites - array of the available sprite images <Array>
      • name - name of the sprite <String>
      • url - css path to the sprite <String>
      • type - type of the sprite (e.g. png) <String>
      • contents - contents of the sprite <Buffer>
      • dpi - dpi value <Number>
      • ratio - scaling ratio of the sprite <Number>
      • width - width of the sprite <Number>
      • height - height of the sprite <Number>
      • baseWidth - width of the smallest dimension of the sprite <Number>
      • baseHeight - height of the smallest dimension of the sprite <Number>

Example template:

{{#each layouts}}
  {{#each sprites}}

    {{#if dpi}}
    @media (-webkit-min-device-pixel-ratio: {{ratio}}), (min-resolution: {{dpi}}dpi) {
    {{/if}}
    .testClass {
      background-image: url('{{escimage url}}');
      {{#if dpi}}
      background-size: {{width}} {{height}};
      {{/if}}
    }
    {{#if dpi}}
    }
    {{/if}}
  {{/each}}

  {{#each layout.items}}
  .{{../classname}}-{{meta.name}} {
    background-position: {{x}} {{y}};
    width: {{width}}px;
    height: {{height}}px;
  }
  {{/each}}
{{/each}}