NodeV2.fromTag constructor

NodeV2.fromTag(
  1. NodeV2 parent,
  2. Tag tag
)

creates a node from a parent and a tag.

Implementation

factory NodeV2.fromTag(NodeV2 parent, Tag tag) {
  List<SimpleProperty> properties = [];

  for (String propertyKey in tag.properties.keys) {
    if (propertyKey == "style") {
      properties
          .add(StyleProperty.fromStyleString(tag.properties[propertyKey]));
    } else {
      properties
          .add(SimpleProperty(propertyKey, tag.properties[propertyKey]));
    }
  }

  return NodeV2._(parent, tag.name, tag.rawTag, properties,
      isCustomTag: tag.isCustomTag, endTagName: tag.endTagName);
}