PHPackages                             enzonagata/template-buffer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. enzonagata/template-buffer

ActiveLibrary

enzonagata/template-buffer
==========================

Template engine with php buffer

v0.2.9(8y ago)135MITPHPPHP &gt;=7.1.0

Since Apr 18Pushed 8y agoCompare

[ Source](https://github.com/enzonagata/template-buffer)[ Packagist](https://packagist.org/packages/enzonagata/template-buffer)[ RSS](/packages/enzonagata-template-buffer/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (21)Used By (0)

Template render with **PHP buffer and Slim 3**
----------------------------------------------

[](#template-render-with-php-buffer-and-slim-3)

Only use files with **\*.phtml** extension, for the moment can not be changed.

---

Class Template;
---------------

[](#class-template)

### **Get started**

[](#get-started)

```
$View = new Template($container);
```

### **Configuring Layout path** - Root directory

[](#configuring-layout-path---root-directory)

```
$dir = 'path/subpath';
$View->setLayoutPath($dir);
```

### **Configuring Templates path** - Root directory

[](#configuring-templates-path---root-directory)

```
$dir = 'path/subpath';
$View->setTemplatePath($dir);
```

### **Create variables to access in to Templates and Layouts**

[](#create-variables-to-access-in-to-templates-and-layouts)

```
$var = array(); || $var = (string); || $var = (integer);
$View->set('nome_variavel', mixed $var);
```

#### **How to access variables in to Template or Layout files**

[](#how-to-access-variables-in-to-template-or-layout-files)

```

    =>

```

### **Rendering template**

[](#rendering-template)

```
//Obs.: file name without extension
$View->render('file_name');

//If it is in a subdirectory of the configured Template folder.
//Obs.: file name without extension
$View->render('path_name/file_name');
```

Class Html;
-----------

[](#class-html)

This class has been extended by default in the Template class, and can be accessed with the public variable *$View-&gt;Html*

### **Adding CSS in Layout**

[](#adding-css-in-layout)

```
//Don't write with extension *.css
$View->Html->addStyles(array(),$option(String('top','bottom')));
//ex:
$View->Html->addStyles(['styles','admin/index'],$option);
```

### **Displaying css in layout**

[](#displaying-css-in-layout)

```
