-
Notifications
You must be signed in to change notification settings - Fork 23
Templating hints
Jan Dolejší edited this page Oct 23, 2019
·
3 revisions
Let's consider a JSON structure defining all drivers.
"drivers": [
{
"name": "driver1",
"status": "on-duty",
"location": "office"
},
{
"name": "driver2",
"status": "off-duty",
"location": "home"
}
]
This is a simple way how to list the driver names:
(:objects
{{data.drivers|map("name")|join(" ")}} - driver
)
The template above outputs this PDDL:
(:objects
driver1 driver2 - driver
)
;;( drivers
{% for driver in data.drivers %}
; Driver: {{driver.name}}
(at {{driver.name}} {{driver.location}})
{% if driver.status == 'on-duty' %}
(available {{driver.name}})
{% endif %}
{% endfor %}
;;)
... outputs ...
;;( drivers
; Driver: driver1
(at driver1 office)
(available driver1)
; Driver: driver2
(at driver2 home)
;;)
https://stackoverflow.com/questions/9486393/jinja2-change-the-value-of-a-variable-inside-a-loop
https://stackoverflow.com/questions/2061439/string-concatenation-in-jinja https://stackoverflow.com/questions/19161093/convert-integer-to-string-jinja