Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 1 | [TOC](Readme.md) [Prev](aliases.md) [Next](hidden.md) |
| 2 | |
Marcel van Lohuizen | af0932f | 2019-01-11 13:03:56 +0100 | [diff] [blame] | 3 | _References and Visibility_ |
| 4 | |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 5 | # Emit Values |
| 6 | |
| 7 | By default all top-level fields are emitted when evaluating a configuration. |
| 8 | CUE files may define a top-level value that is emitted instead. |
Jonathan Amsterdam | e479038 | 2019-01-20 10:29:29 -0500 | [diff] [blame] | 9 | <!-- jba: |
| 10 | It's unclear how they do that. Is it the first form in the file? |
| 11 | And this is not in the spec AFAICT. |
| 12 | --> |
Marcel van Lohuizen | 75cb003 | 2019-01-11 12:10:48 +0100 | [diff] [blame] | 13 | |
| 14 | Values within the emit value may refer to fields defined outside of it. |
| 15 | |
| 16 | Emit values allow CUE configurations, like JSON, |
| 17 | to define any type, instead of just structs, while keeping the common case |
| 18 | of defining structs light. |
| 19 | |
| 20 | <!-- CUE editor --> |
| 21 | ``` |
| 22 | { |
| 23 | a: A |
| 24 | b: B |
| 25 | } |
| 26 | |
| 27 | A: 1 |
| 28 | B: 2 |
| 29 | ``` |
| 30 | |
| 31 | <!-- result --> |
| 32 | ``` |
| 33 | a: 1 |
| 34 | b: 2 |
Jonathan Amsterdam | e479038 | 2019-01-20 10:29:29 -0500 | [diff] [blame] | 35 | ``` |