Skip to content

Commit 952380f

Browse files
doc: add information about windows path in variables
1 parent 99484bf commit 952380f

File tree

1 file changed

+36
-4
lines changed
  • docs/content/configuration/variables

1 file changed

+36
-4
lines changed

Diff for: docs/content/configuration/variables/index.md

+36-4
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,17 @@ profile src:
349349
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`.
350350
Now you can reuse the same generic configuration in another profile.
351351

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).
354353

355354
### Hand-made variables
356355

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:
359363

360364
```yaml
361365
# declare and assign a value to the variable
@@ -369,6 +373,34 @@ profile:
369373
Variables are only valid in the file they are declared in. They cannot be shared in files loaded via `include`.
370374
{{% /notice %}}
371375

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+
372404
#### Example
373405

374406
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

Comments
 (0)