begin method

  1. @override
void begin(
  1. TagContext tc,
  2. String data
)
override

Called when the beginning of a tag is encountered.

Implementation

@override
void begin(TagContext tc, String data) {
  final attrs = parseArgs(data);
  if (!attrs.isEmpty) {
    tc.write("\n${tc.pre}response.headers");
    bool first = true;
    for (final nm in attrs.keys) {
      final val = attrs[nm];
      if (val == null)
        tc.error("The $nm attribute requires a value.");

      if (first) first = false;
      else tc.write("\n${tc.pre}  ");
      tc.write('..add("$nm", ${toEL(val)})');
    }
    tc.writeln(';${tc.getLineNumberComment()}');
  }
}