Skip to content

northphp/template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Template

Build Status

A simple template system.

Installation

composer require north/template

Examples

More docs here

use North\Template\Template;

$template = new Template('path/to/templates');

$template->render('index');

index.php

<?php $this->extend('layouts/app', ['title' => 'Startpage']) ?>
<?php $this->block('content') ?>
    <?php $this->include('partials/content', ['title' => 'Hello, world']) ?>
<?php $this->endblock() ?>

layouts/app.php

<!doctype html>
<html>
  <head>
    <title><?php echo $this->escape($title) ?></title>
  </head>
  <body>
    <?php $this->yield('content') ?>
  </body>
</html>

partials/content.php

<div class="content">
    <h1><?php echo $this->escape($title) ?></h1>
</div>

More examples in the tests/TemplateTest.php

License

MIT © Fredrik Forsmo