getOptionsFromString method

YamlMap getOptionsFromString (
  1. String optionsSource
)

Provide the options found in optionsSource. An include directive, if present, will be left as-is, and the referenced options will NOT be merged into the result. Return an empty options map if the source is null.

Implementation

YamlMap getOptionsFromString(String optionsSource) {
  if (optionsSource == null) {
    return YamlMap();
  }
  try {
    YamlNode doc = loadYamlNode(optionsSource);
    if (doc is YamlMap) {
      return doc;
    }
    return YamlMap();
  } on YamlException catch (e) {
    throw OptionsFormatException(e.message, e.span);
  } catch (e) {
    throw OptionsFormatException('Unable to parse YAML document.');
  }
}