$value) { $result = \str_replace(\sprintf('{{%s}}', $key), $value, $result); } return $result; } function template_render_by_name( string $template_name, array $arguments ) : string { return string_coin( \file_get_contents(\sprintf('%s/%s.html.tpl', __DIR__, $template_name)), $arguments ); } function main( ) : void { $data = \json_decode( \file_get_contents('data.json'), true ); print( template_render_by_name( 'main', [ 'title' => $data['title'], 'entries' => \implode( "\n", \array_map( fn($entry) => template_render_by_name( 'entry', [ 'label' => $entry['label'], 'target' => $entry['target'], ] ), $data['entries'] ) ), ] ) ); } main(); ?>