Hubert

Template

Hubert uses Plates as template engine.

Installation

At first you have to extend the configuration of composer:

{
    "require": {
        "falkm/hubert-template": "1.*"
    }
}

Configuration

Afterwards you have to extend the configuration of Hubert or create a new config/template.global.php file. In the following example we define for instance that templates will be place in a /templates directory and have a .phtml file extension.

<?php
return array(
    "factories" => array(
        "template" => array(hubert\extension\template\factory::class, 'get')
    ),
    "config" => array(
        "template" => array(
            "path" => dirname(__dir__).'/templates',
            "fileExtension" => "phtml",
            "extensions" => array(
                hubert\extension\template\urlExtension::class
            )
        )
    )
);

Usage

$html = hubert()->template->render("index/index", array("name" => "hubert"));

This command for instance renders the template "templates/index/index.phtml". In the template is a $name variable available. Using the following command you can insert a template variable globally.

hubert()->template->addData(array("language" => 'de'));

Read more about templates and their best practice on platesphp.com.