1. Go to this page and download the library: Download salesforce/handlebars-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
salesforce / handlebars-php example snippets
# With composer we can autoload the Handlebars package
equire 'src/Handlebars/Autoloader.php';
# Handlebars\Autoloader::register();
use Handlebars\Handlebars;
use Handlebars\Loader\FilesystemLoader;
# Set the partials files
$partialsDir = __DIR__."/templates";
$partialsLoader = new FilesystemLoader($partialsDir,
[
"extension" => "html"
]
);
# We'll use $handlebars throughout this the examples, assuming the will be all set this way
$handlebars = new Handlebars([
"loader" => $partialsLoader,
"partials_loader" => $partialsLoader
]);
# Will render the model to the templates/main.tpl template
$model = [...];
echo $handlebars->render("main", $model);