buildHTML method

String buildHTML({
  1. bool withIndent = false,
  2. String parentIndent = '',
  3. String indent = ' ',
  4. bool disableIndent = false,
  5. bool xhtml = false,
  6. DSXResolution dsxResolution = DSXResolution.skipDSX,
  7. bool buildTemplates = false,
  8. DOMNode? parentNode,
  9. DOMNode? previousNode,
  10. DOMContext<Object>? domContext,
})

Generates a HTML from this node tree.

withIndent If true will generate a indented HTML.

Implementation

String buildHTML({
  bool withIndent = false,
  String parentIndent = '',
  String indent = '  ',
  bool disableIndent = false,
  bool xhtml = false,
  DSXResolution dsxResolution = DSXResolution.skipDSX,
  bool buildTemplates = false,
  DOMNode? parentNode,
  DOMNode? previousNode,
  DOMContext? domContext,
}) {
  if (isCommented) return '';

  final content = _content;
  if (content == null || content.isEmpty) return '';

  var html = StringBuffer();

  DOMNode? prev;
  for (var node in content) {
    var subHtml = node.buildHTML(
      withIndent: withIndent,
      // A `DOMNode` has no tag: its content is at its own indentation.
      parentIndent: parentIndent,
      indent: indent,
      disableIndent: disableIndent,
      xhtml: xhtml,
      dsxResolution: dsxResolution,
      buildTemplates: buildTemplates,
      parentNode: parentNode,
      previousNode: prev,
      domContext: domContext,
    );
    html.write(subHtml);
    prev = node;
  }

  return html.toString();
}