render(); } protected function e(string $s): string { return esc_html($s); } protected function a(string $s): string { return esc_attr($s); } protected function u(string $s): string { return esc_url($s); } /** * An element with attribute-escaped values. A null value drops the attribute, so a * conditional attribute (`'disabled' => $busy ? '' : null`) needs no branching at the * call site. `$inner` is used as given: the caller has already escaped it, or it is * another component's output. Only attribute *values* are escaped: `$name` and the * attribute names are written raw, so they must be literals in the calling code, never data. * * @param array $attrs */ protected function tag(string $name, array $attrs, string $inner = ''): string { $a = ''; foreach ($attrs as $k => $v) { if ($v === null) { continue; } $a .= sprintf(' %s="%s"', $k, $this->a($v)); } return in_array($name, self::VOID, true) ? "<{$name}{$a}>" : "<{$name}{$a}>{$inner}"; } }