Skip to content

Syntactic sugar

Jarno Elovirta edited this page Apr 21, 2022 · 10 revisions

The theme files can contain syntactic sugar to make writing files easier. When theme files are read, they are "desugared" before passing the theme files to stylesheet generator.

Content

The authoring format of content key is DSL that support field and variable references mixed with text.

content: "{#copyright} {year} ACME Corporation"

desugars to

content:
- kind: variable  
  value: copyright
- kind: text  
  value: " "
- kind: field
  value: year
- kind: text  
  value: " ACME Corporation"

this could result in for example

© 2022 ACME Corporation

Page dimensions

When page dimensions are defined using size and orientation and keys, they are desugared to width and height keys using mapping table for known page sizes.

page:
  size: A4

desugars to

page:
  width: 210mm
  height: 297mm

Header and footer

Style keys for header and footer are collected under odd and even keys.

header:
  color: silver
  odd:
    font-weight: bold

desugars to

header:
  odd:
    font-weight: bold
    color: silver
  even:
    color: silver
Clone this wiki locally