Variables et expressions

Créez des variables réutilisables qui peuvent être référencées dans les pages et les espaces

Avec des variables, vous pouvez créer du texte réutilisable qui peut être référencé de manière conditionnelle dans expressions et conditions pour un contenu adaptatif.

If you repeat the same name, phrase or version number multiple times within your content, you can create a variable to help keep all those instances in sync and accurate — which is useful if you ever need to update them, or they’re complex and often mistyped.

You can create variables that are scoped to a single page, or a single space.

Créer une nouvelle variable

To create a new variable, Click the Variables icône dans le coin supérieur droit lors de l'édition d'un(e) demande de modification. This will open the Variables side panel.

You can use the toggle at the top to view and create variables scoped either to the current page you’re on, or all pages within the current space.

En cliquant sur Créer une variable will launch a modal where you can give your variable a name and a value.

Cliquez sur Ajouter une variable to save your variable.

A GitBook screenshot showing the Add variables screen. The variable Name box has been filled with the text ‘latest_version’ and the Value box has been filled with the text ‘v3.04.1’
You can add variables to a single page or an entire space. When you update the value of a variable, every instance of it will update.

Variable names must start with a letter, and can contain letters, numbers and underscores.

Utilisez des variables dans votre contenu

Les variables peuvent être référencées et utilisées dans une expression — which you can insert into your content inline. After inserting an expression, double click it to open the expression editor.

Les variables définies sous votre page sont accessibles sous le page.vars object. Similarly, variables defined across your entire space are accessible under the space.vars object.

A GitBook screenshot showing an expression block within the editor. The expression editor is open below it and the ‘space.vars.latest_version’ variable has been selected
You can add variables to your content within expresions. The expression editor offers autocomplete options to help you find the variable you need.

Mettre à jour une variable

You can update a variable at any point when within a change request. Updating its value will update the value across any expression blocks referencing it. The changed variable will go live to any published site once the change request is merged.

Mis à jour

Ce contenu vous a-t-il été utile ?