Skip to content

Support attributes indentation and few minor improvements

Compare
Choose a tag to compare
@nashwaan nashwaan released this 03 Oct 12:52
· 67 commits to master since this release

This release supports a new option indentAttributes to indent attributes in the xml. See below example from this thread:

<parent
  bar="1"
  baz="hello"
>
  <child
    attr1="a"
    attr2="b"
  />
</parent>

Also, support for converting js object of {a: 'hi'} rather than {a: {_text: 'hi'}} to <a>hi</a>.
I previously didn't want to support this for the reasons outlined here.
I am allowing this behavior in this library as it can be safe to handle this scenario when transforming js2xml only.
xml2js conversion from <a>hi</a> to {a: 'hi'} rather than {a: {_text: 'hi'}} is still not supported as this could be dangerous for the reasons explained here.