Unexpected format after yaml encoding array

I have a pages collection, I pluck the uri from each page into array, then yaml encode it, to programatically update a pages field, something like this:

// consider I have a valid collection in $selectedWorksPages, and a valid page in $p
$selectedWorks = $selectedWorksPages->pluck('uri');
$p->update([
    'selectedworks' => Data::encode($selectedWorks, 'yaml')
]);

In the .txt file, this results in a list with a mixed format, such as:

Selectedworks:

- artworks/cratere-6237
- artworks/keats-between-cubes-6239
- >
  artworks/division-of-the-square-nietzsche-6240
- >
  artworks/division-of-the-square-a-couple-6241
- >
  artworks/cube-the-picture-of-dorian-gray-6242
- artworks/8-arms-with-times-6243
- >
  artworks/angolo-stanco-hommage-a-la-mort-de-walter-benjamin-6244
- artworks/marble-between-1-year-6245
- >
  artworks/old-chair-with-old-shoes-old-capital-but-new-newspaper-6246
- artworks/medio-pollice-rosa-6247

Why ? is this ok ?

Thanks

The format with the > characters is YAML’s so-called “folded style block notation” and is equivalent to the plain style string (well, strictly speaking an \n end of line character is added when parsing, but Kirby apparently takes care of that when decoding). The Spyc library, used by Kirby to do YAML transformations switches to the folded style automatically for all strings longer than 40 characters.

Long story short: this is ok, and actually intended behaviour :slight_smile:

Additional info: There is also the pipe | for multiline text.

Thank you for the explanation.

Btw @texnixe, is there a more straightforward way to store a pages collection into a pages field than to pluck the uris, then yaml encode ?

Thanks