// Load the template file $template = new \League\Plates\Engine(dirname(__FILE__) . '/templates'); // Define the data for the template $data = [ 'name' => 'John Smith', 'email' => 'john@smith.com', 'picture' => 'https://example.com/picture.jpg' ]; // Render the template and output the result echo $template->render('user_profile', $data);
// Load the template file $template = new \Twig\Environment(new \Twig\Loader\FilesystemLoader('templates')); // Define the data for the template $data = [ 'products' => [ [ 'name' => 'Product 1', 'description' => 'This is the first product.', 'price' => '$10.00' ], [ 'name' => 'Product 2', 'description' => 'This is the second product.', 'price' => '$20.00' ], [ 'name' => 'Product 3', 'description' => 'This is the third product.', 'price' => '$30.00' ] ] ]; // Render the template and output the result echo $template->render('product_list.twig', $data);In this example, the `Twig` package is used to load the template file and render the data using the `render` function. The data is an array of products with each product having a name, description and price. The template file contains a loop that goes through the array and generates a product listing for each item.