buildHTML method

String buildHTML({
  1. DOMContext? domContext,
  2. bool resolveDSX = false,
})

Implementation

String buildHTML({DOMContext? domContext, bool resolveDSX = false}) {
  var valueHandler = this.valueHandler;

  if (isBoolean) {
    return valueHandler.hasAttributeValue ? name : '';
  }

  String? htmlValue;
  if (resolveDSX && valueHandler is DOMAttributeValueTemplate) {
    var templateBuilt = valueHandler.template.build(domContext,
        asElement: false,
        resolveDSX: resolveDSX,
        intlMessageResolver: domContext?.intlMessageResolver);

    if (templateBuilt is String && !possiblyWithHTML(templateBuilt)) {
      htmlValue = templateBuilt;
    } else {
      var nodes = DOMNode.parseNodes(templateBuilt);
      htmlValue = nodes.map((e) => e.text).join();
    }
  } else {
    htmlValue = valueHandler.getAttributeValue(domContext);
  }

  if (htmlValue != null) {
    var html = '$name=';
    html += htmlValue.contains('"') ? "'$htmlValue'" : '"$htmlValue"';
    return html;
  } else {
    return '';
  }
}