Add further section on conditional access

This commit is contained in:
Laurenz 2025-06-19 18:52:47 +02:00
parent f1d10fc96f
commit 4ce7ad142f

View File

@ -157,6 +157,29 @@
#lorem(10)
```
# Conditional access
You can also use this in combination with the [dictionary
constructor]($dictionary) to conditionally access global definitions. This
can, for instance, be useful to use new or experimental functionality (like
the [`target`] function) when it is available, while falling back to an
alternative implementation if used on an older Typst version.
```example
#let target = dictionary(std).at(
"target",
default: () => "paged",
)
#context if target() == "html" [
HTML
] else [
Paged
]
```
Make sure to use this functionality responsibly as the behavior of your code
can change with new Typst versions!
- name: sys
title: System
category: foundations