Data sections

Inluding data in ZML

You can include data inside ZML by declaring context-nodes with a $-prefix. The context nodes are accessed with dot notation inside moustaches:

# import components
# inherit base

$users:
  -
    firstname: 'Richard'
    lastname: 'Langly'
    email: 'ringo@l4ngly.org'
    active: True
  -
    firstname: 'Melvin'
    lastname: 'Frohike'
    email: 'melvin@frohike1.net'
    active: True
  -
    firstname: 'John Fitzgerald'
    lastname: 'Byers'
    email: 'jfb@byers23.org'
    active: True

$pages:
  -
    title: 'About'
    url: '/about'
  -
    title: 'Services'
    url: '/services'
  -
    title: 'Contact'
    url: '/contact'

$page:
  stylesheets:
    - 'files/css/base.css'
    - 'files/css/content.css'
  scripts:
    - 'files/js/jquery.js'
    - 'files/js/main.js'

$test1:
  test2:
    test3: 4+3

*content:
  %for user in users:
    div.card:
       %if user.active:
         p: {user.firstname}
         p: {user.lastname}
         p: {user.email}
       %else:
         p: The user is not active
  div: {test1.test2.test3}