summaryrefslogtreecommitdiff
path: root/lib/Katana/HTML/Tag.rakumod
blob: 50d558564845630f94d98a5ec89f29018cc56724 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use v6.d;
unit class Katana::HTML::Tag is export;

has Str $.name;
has Str $.text;
has Str %.params;
has Bool $.is-mono = False;
has Katana::HTML::Tag @.succ;

method has-text returns Bool { defined $.text }
method has-succ returns Bool { defined $.succ }

method open returns Str {
  return "<{$.name}{self.params} />" if $!is-mono;
  return "<{$.name}{self.params}>"
}
method close returns Str { "</{$.name}>" }

method params returns Str {
  return '' unless defined %!params;
  my @params;
  for %!params.kv -> $key, $val {
    push @params, " $key='$val'";
  }
  return @params.join;
}