decorators-squad/eo-yaml

YamlSequence: print without extra newLine

Opened this issue · 5 comments

first of all, thank you for sure a great project ! I really love it!

So according to our specs, we should emit complex sequences without extra newLine like this:

- item    : Super Hoop
  quantity: 1
- item    : Basketball
  quantity: 4
- item    : Big Shoes
  quantity: 1

but i can't find out how to achive it:

    YamlSequenceBuilder sequence = Yaml.createYamlSequenceBuilder();

    YamlMappingBuilder compactNestedMapping = Yaml.createYamlMappingBuilder();
    compactNestedMapping = compactNestedMapping.add("item", "Super Hoop");
    compactNestedMapping = compactNestedMapping.add("quantity", "1");

    sequence = sequence.add(compactNestedMapping.build());

always produce :

-
  item: Super Hoop
  quantity: 1

i am totally sure, i do something wrong

Thanks for any ideas

@treblereel thank you for reporting this. I'll assign someone to take care of it soon.

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.

@treblereel Unfortunately, there is no way of customizing the printing logic, at the moment. There is another similar ticket and we're thinking about it. However, this is honestly speaking low prio at the moment.

But the printed YAML you get is valid, it respects the YAML spec. If some other system is consuming your YAMLs and it cannot read what is currently printed, then I think you should report a bug on their side.

Also, keep in mind that the library is based on interfaces, so you can most likely implement your own printer/visitor as a set of decorators. I think that's how we did it initially, but it became more complex when we implemented YAML Comments. If you're not interested in the comments, I think such a decorating printer should be easy to implement.

@amihaiemil got it, thanks a lot for the advice.

@amihaiemil I couldn't find any assignee for this task. This is either because there are no contributors with role DEV available or because the project does not have enough funds.

Please, make sure there is at least one available contributor with the required role and the project can afford to pay them.