You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/configuration/variables/index.md
+36-4
Original file line number
Diff line number
Diff line change
@@ -349,13 +349,17 @@ profile src:
349
349
As you can see, the `src` profile inherited from the `generic` profile. The tags `{{ .Profile.Name }}` got replaced by the name of the current profile `src`.
350
350
Now you can reuse the same generic configuration in another profile.
351
351
352
-
You might have noticed the `read-data-subset` in the `check` section which will read a seventh of the data every day, meaning the whole repository data will be
353
-
checked over a week. You can find [more information about this trick](https://stackoverflow.com/a/72465098).
352
+
You might have noticed the `read-data-subset` in the `check` section which will read a seventh of the data every day, meaning the whole repository data will be checked over a week. You can find [more information about this trick](https://stackoverflow.com/a/72465098).
354
353
355
354
### Hand-made variables
356
355
357
-
But you can also define variables yourself. Hand-made variables starts with a `$` ([PHP](https://en.wikipedia.org/wiki/PHP) anyone?) and get declared and
358
-
assigned with the `:=` operator ([Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) anyone?). Here's an example:
356
+
You can also define variables yourself. Hand-made variables starts with a `$` ([PHP](https://en.wikipedia.org/wiki/PHP) anyone?) and get declared and assigned with the `:=` operator ([Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language)) anyone?).
357
+
358
+
{{% notice style="info" %}}
359
+
You can only use double quotes `"` to declare the string, single quotes `'` are not allowed. You can also use backticks to declare the string.
360
+
{{% /notice %}}
361
+
362
+
Here's an example:
359
363
360
364
```yaml
361
365
# declare and assign a value to the variable
@@ -369,6 +373,34 @@ profile:
369
373
Variables are only valid in the file they are declared in. They cannot be shared in files loaded via `include`.
370
374
{{% /notice %}}
371
375
376
+
Variables can be redefined using the `=` operator. The new value will be used from the point of redefinition to the end of the file.
377
+
378
+
```yaml
379
+
# declare and assign a value to the variable
380
+
{{ $name := "something" }}
381
+
382
+
# reassign a new value to the variable
383
+
{{ $name = "something else" }}
384
+
385
+
```
386
+
387
+
#### Windows path inside a variable
388
+
389
+
Windows path are using backslashes `\` and are interpreted as escape characters in the configuration file. To use a Windows path inside a variable, you have a few options:
390
+
- you can escape the backslashes with another backslash.
391
+
- you can use forward slashes `/` instead of backslashes. Windows is able to use forward slashes in paths.
392
+
- you can use the backtick to declare the string instead of a double quote.
393
+
394
+
For example:
395
+
```yaml
396
+
# double backslash
397
+
{{ $path := "C:\\Users\\CP\\Documents" }}
398
+
# forward slash
399
+
{{ $path := "C:/Users/CP/Documents" }}
400
+
# backticks
401
+
{{ $path := `C:\Users\CP\Documents` }}
402
+
```
403
+
372
404
#### Example
373
405
374
406
Here's an example of a configuration on Linux where I use a variable `$mountpoint` set to a USB drive mount point:
0 commit comments