setTemplateDir('path/to/templates'); // set compile directory $smarty -> setCompileDir('path/to/compiled'); // assign variables to template $smarty -> assign('title', 'My Website'); $smarty -> assign('content', 'Hello World!'); // display rendered template $smarty -> display('index.tpl'); ?>
render('index.html', array( 'title' => 'My Website', 'content' => 'Hello World!' )); ?>In this example, the Twig package is used to render a template called "index.html". The `Twig_Loader_Filesystem` class is used to specify the template directory, and variables are passed to the template using an associative array. Both Smarty and Twig are popular packages for PHP template loading, each with their own pros and cons. However, there are many other PHP package libraries available for template loading, including Blade and Mustache.