renderElementChild method

void renderElementChild(
  1. Element parent,
  2. ElementChild child,
  3. CodeBuffer buffer,
  4. SymbolTable scope,
  5. bool html5,
  6. int index,
  7. int total,
)

Implementation

void renderElementChild(Element parent, ElementChild child, CodeBuffer buffer,
    SymbolTable scope, bool html5, int index, int total) {
  if (child is Text && parent.tagName.name != 'textarea') {
    if (index == 0) {
      buffer.write(child.span.text.trimLeft());
    } else if (index == total - 1) {
      buffer.write(child.span.text.trimRight());
    } else {
      buffer.write(child.span.text);
    }
  } else if (child is Interpolation) {
    var value = child.expression.compute(scope);

    if (value != null) {
      if (child.isRaw) {
        buffer.write(value);
      } else {
        buffer.write(htmlEscape.convert(value.toString()));
      }
    }
  } else if (child is Element) {
    if (buffer.lastLine?.text.isNotEmpty == true) buffer.writeln();
    renderElement(child, buffer, scope, html5);
  }
}