PHP code example of brbunny / brplates

1. Go to this page and download the library: Download brbunny/brplates 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/ */

    

brbunny / brplates example snippets




use BrBunny\BrPlates\BrPlates;

class Controller
{
    /** @var BrPlates; */
    private $view;

    public function __construct($path, $ext)
    {
        // $this->view = new BrPlates($path, $ext);
        $this->view = new BrPlates($path); //Extension is optional
    }
}



// Register a one-off function
$this->view->function("name", function ($params) {
    // Type Code
});



// Get template from another directory
$this->view->path("profile", "./theme/profile");

//Use template
$this->view->show("profile::profile", ["user" => "Jow User"]);

// Remove template added
$this->view->removePath("profile");


//
$this->view->data(['company' => 'BrPlates'], ["_theme", "home"]);
$this->view->data(['company' => 'BrPlates']); // Template is Optional


$template = $view->render("_theme", ["user" => "Jow User"]);
echo $template;

$this->view->show("_theme", ["user" => "Jow User"]);



if ($this->view->isset("_theme")) {
   // Exist
}

/*
Content of the widgets::list template:

<ul>
    <?= $this->section('widgets') 


/*
Content of the widgets::children template:

<li>
    <?= $label 


/*
Content of the widgets::item template:

<li><?= $content 



echo $view->renderMinify("profile::profile", ["user" => "Jow User"]);

<script js-mix>
    // Alert
    alert('minify');
</script>

// Result
<script>alert('minify');</script>