How to write a custom Kirbytag?

Thank you @texnixe for your help, I slowly understand the Kirby tags basics.
This tag I use to insert "cleaner"a table.

<?php
Kirby::plugin('strukturart/table', [
'tags' => [
    'table' => [
      'attr' =>[
        'table_name'
      ],
        'html' => function($tag) {
          $field = $tag->table_name;
          
          $html = '<table class="kirbytag-table">';

			foreach(page()->$field()->toStructure() as $table) 
			{
				$html .= '<tr>';
				$html .= '<td>';
				$html .= $table->col01()->html();
				$html .= '</td>';
				$html .= '<td>';
				$html .= $table->col02()->html();
				$html .= '</td>';
				$html .= '<td>';
				$html .= $table->col03()->html();
				$html .= '</td>';
				$html .= '</tr>';
			}

			$html .= '</table>';

return $html;

        }
    ]
]
]);


?>