From 4ce7ad142ff849c19340a67b4b30c43b63a32c6a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 19 Jun 2025 18:52:47 +0200 Subject: [PATCH] Add further section on conditional access --- docs/reference/groups.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/reference/groups.yml b/docs/reference/groups.yml index 3222372b9..52b864f33 100644 --- a/docs/reference/groups.yml +++ b/docs/reference/groups.yml @@ -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