Skip to content

Commit

Permalink
Move section on indented strings after string interpolation (#1030)
Browse files Browse the repository at this point in the history
Proposing to move the "_Indented strings_" section after "_String interpolation_" because I think it fits better there logically. Also added a note that string interpolation works in indented strings as well.
  • Loading branch information
toraritte authored Jan 7, 2025
1 parent 439f2d8 commit 232e7bd
Showing 1 changed file with 48 additions and 45 deletions.
93 changes: 48 additions & 45 deletions source/tutorials/nix-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,54 @@ in

<!-- TODO: link to escaping rules -->

(indented-strings)=
### Indented strings

Also known as “multi-line strings”.

The Nix language offers convenience syntax for character strings which span multiple lines that have common indentation.

Indented strings are denoted by *double single quotes* (`'' ''`).

Example:

```{code-block} nix
:class: expression
''
multi
line
string
''
```

```{code-block}
:class: value
"multi\nline\nstring\n"
```

Equal amounts of prepended white space are trimmed from the result.

Example:

```{code-block} nix
:class: expression
''
one
two
three
''
```

```{code-block}
:class: value
"one\n two\n three\n"
```

:::{note}
Indented strings also support [string interpolation](string-interpolation).
For details check the [documentation on string literals in the Nix language](https://nix.dev/manual/nix/2.24/language/syntax#string-literal).
:::

(file-system-paths)=
### File system paths

Expand Down Expand Up @@ -1003,51 +1051,6 @@ While you will encounter many such examples, we recommend to [avoid lookup paths
[nixpkgs]: https://github.com/NixOS/nixpkgs
[manual-primitives]: https://nix.dev/manual/nix/stable/language/values.html#primitives

(indented-strings)=
### Indented strings

Also known as “multi-line strings”.

The Nix language offers convenience syntax for character strings which span multiple lines that have common indentation.

Indented strings are denoted by *double single quotes* (`'' ''`).

Example:

```{code-block} nix
:class: expression
''
multi
line
string
''
```

```{code-block}
:class: value
"multi\nline\nstring\n"
```

Equal amounts of prepended white space are trimmed from the result.

Example:

```{code-block} nix
:class: expression
''
one
two
three
''
```

```{code-block}
:class: value
"one\n two\n three\n"
```

<!-- TODO: See [escaping rules](). -->

(functions)=
## Functions

Expand Down

0 comments on commit 232e7bd

Please sign in to comment.