Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move section on indented strings after string interpolation #1030

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 49 additions & 45 deletions source/tutorials/nix-language.md
Original file line number Diff line number Diff line change
@@ -848,6 +848,55 @@ 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). See the section on Nix's [`string`](https://nix.dev/manual/nix/stable/language/values#type-string) type in the [Nix manual](https://nix.dev/manual/nix/stable/).
:::

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

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

@@ -975,51 +1024,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