<?php

namespace prj\{{.Root}}\outputs\{{.Subfolder}};

class {{.File}}_out {
    
    public static function {{.Method}}(array $input): array {

        $first_name = $input['html']['first_name'] ?? "";
        $last_name = $input['html']['last_name'] ?? "";

        $ret['main'] = ($input['errors']) ? "" : "Hello {$first_name}, {$last_name}!" . PHP_EOL;
        $ret['errors'] = $input['errors'];
        $ret['model'] = $input['model'];
        
        return $ret;
    }

    public static function {{.Method}}_show_errors(array $errors): string {
        if ($errors) {
            $message = "Please correct the following errors: ";
            $i = 0;
            foreach($errors as $error) {
                $i++;
                $message .= "<br/>{$i}) " . $error;
            }
            return $message;
        }
        return ""; // No Errors to return here
    }

    public static function {{.Method}}_display(\Generator $input): void {
        if (! $input->current()) {
            return; // No Data, so Bail here
        }
        \tts\html::show_table_from_generator(
            ['ID', 'First Name', 'Last Name'],
            ['id', 'first_name', 'last_name'],
            $input
        );
    }

}
