Skip to content

A lightweight and mostly native php template engine.

Notifications You must be signed in to change notification settings

bosoy83/template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Favez Template

A lightweight and mostly native php template engine supporting nested blocks.

Installation

$ composer require favez/template

Basic usage

index.php

<?php

require_once __DIR__ . '/vendor/autoload.php';

\Favez\Template\Environment::addTemplateDir(__DIR__ . '/views');

$template = \Favez\Template\Environment::create('index.phtml');
$template->assign('username', 'tyurderi');

index.phtml

<!DOCTYPE html>
<html>
<head>
    <title>Favez Template</title>
</head>
<body>
    Hello, <?php echo $username?>!
</body>
</html>

Including other templates

<?php $this->import('path/to/template.phtml')?>

Basic usage for (nested) blocks

index.phtml

<!DOCTYPE html>
<html>
<head>
    <title><?php $this->block('title')>Home<?php $this->endblock()?> | Favez Template</title>
</head>
<body>
<?php $this->block('body')?>
Hello World
<?php $this->endblock()?>
</body>
</html>

index2.phtml

<?php $this->extend('index.phtml')?>

<?php $this->block('body')?>
    Hello, <?php echo $username?>!
<?php $this->endblock()?>

About

A lightweight and mostly native php template engine.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages