diff --git a/source/tutorials/nix-language.md b/source/tutorials/nix-language.md index 2b1ae57..297b559 100644 --- a/source/tutorials/nix-language.md +++ b/source/tutorials/nix-language.md @@ -848,6 +848,55 @@ in +(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/). +::: + + + (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" -``` - - - (functions)= ## Functions