1<?php 2 3namespace ComboStrap\Template; 4 5use ComboStrap\TemplateEngine; 6 7class TemplateForComponent 8{ 9 10 11 12 private string $templateName; 13 14 public function __construct(string $templateName) 15 { 16 $this->templateName = $templateName; 17 } 18 19 public static function create(string $templateName): TemplateForComponent 20 { 21 return new TemplateForComponent($templateName); 22 } 23 24 public function render(array $data): string 25 { 26 return TemplateEngine::createFromContext() 27 ->renderWebComponent($this->templateName,$data); 28 } 29 30 31} 32