/** * Test handlebars autoloader * * @return void */ public function testAutoLoad() { Handlebars\Autoloader::register(realpath(__DIR__ . '/../fixture/')); $this->assertTrue(class_exists('Handlebars\\Test')); $this->assertTrue(class_exists('\\Handlebars\\Test')); $this->assertTrue(class_exists('Handlebars\\Example\\Test')); $this->assertTrue(class_exists('\\Handlebars\\Example\\Test')); $this->assertFalse(class_exists('\\Another\\Example\\Test')); }
public function __construct() { // Load Handlebars Template Engine require_once 'Handlebars/Autoloader.php'; Handlebars\Autoloader::register(); // Load Plugin Modules require_once 'class-export-id-xml-admin.php'; require_once 'class-export-id-xml-generator.php'; }
// Save the file $data = removeUnnecessaryKeys($_POST, $fonbconfig); $data = array_merge($fonbconfig, $data); unset($data['WebSocket']); $fonb->write_phoneb($data); header("Location: config.php"); exit; } ### UPDATE button if (isset($_POST['action']) && $_POST['action'] == "SAVE") { // Save the file $data = removeUnnecessaryKeys($_POST, $fonbconfig); $data = array_merge($fonbconfig, $data); $fonb->write_phoneb($data); header("Location: config.php"); exit; } ### VIEW the edit user form // Get the Handlebars Template $ConfigTemplateFilePath = realpath("../templates/admin/config.html"); if ($ConfigTemplateFilePath === false) { // Error exit("Template config.html was not found"); } $ConfigTemplate = file_get_contents($ConfigTemplateFilePath); // Last step, output the html file require 'Handlebars/Autoloader.php'; Handlebars\Autoloader::register(); use Handlebars\Handlebars; $engine = new Handlebars(); echo $engine->render($ConfigTemplate, $fonbconfig);
/** * Test custom template class */ public function testValidCustomTemplateClass() { Handlebars\Autoloader::register(realpath(__DIR__ . '/../fixture/')); $loader = new \Handlebars\Loader\StringLoader(); $engine = new \Handlebars\Handlebars(array('loader' => $loader, 'template_class' => 'Handlebars\\CustomTemplate')); $render = $engine->render('Original Template', array()); $this->assertEquals($render, 'Altered Template'); }