Folding long strong without spaces (YAML)

4,959 views
Skip to first unread message

Dan Sullivan

unread,
Mar 26, 2017, 12:48:26 PM3/26/17
to Salt-users
Hi,

I've spent a couple of hours on this and can't figure it out;

Lets say I have a long string with no spaces in it, for example "ABCDEFGHIJKLMNOPQRSTUVWXYZ".  How would I break that into a multiple lines in a pillar entry (using YAML)?  I've tried various techniques described http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines and http://stackoverflow.com/questions/19168734/yaml-multiline-wrap-without-space, however no matter what I do it seems that I can't get the string without a space in it (in the output of pillar.items, for example).

Surely somebody has solved this problem before, for some reason I am struggling to get this done.  I appreciate you taking the time to help me.

Dan

C. Stinger

unread,
Mar 26, 2017, 2:16:56 PM3/26/17
to Salt-users
http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines/21699210#21699210  there is a section in there that talks about how to chomp line endings and trailing spaces

Block styles with block chomping indicator (>-|->+|+)

You can control the handling of the final new line in the string, and any trailing blank lines (\n\n) by adding a block chomping indicator character:

  • >|: "clip": keep the line feed, remove the trailing blank lines.
  • >-|-: "strip": remove the line feed, remove the trailing blank lines.
  • >+|+: "keep": keep the line feed, keep trailing blank lines.
I haven't used these personally but I have had to use the - indicator in jinja for the same purpose so it's worth a shot.

Pieter

unread,
May 23, 2023, 11:38:08 AM5/23/23
to Salt-users
Not working >- adds a space between each line when concatenating. :(
Reply all
Reply to author
Forward
0 new messages