2017 © Pedro Peláez
 

library minplate

A mini template engine for PHP

image

anpv1/minplate

A mini template engine for PHP

  • Sunday, July 15, 2018
  • by phaman86
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

minplate

A mini template engine for PHP, (*1)

Introduction

minplate is a mini template engine for PHP which has a very simple API and easy to learn. minplate use pure PHP so it's super fast and you don't have to learn new syntax. minplate support the below features: - assign variables for the template. - creating block in the layout which can be override. - include/inherite other template file. - allow override the template directory with add_path function. The latest inserted path will be used first., (*2)

That's all!, (*3)

API

function __construct($template_path = './');
function add_path($template_path);
function assign(string $variable_name, $value);
function include(string $template_name);
function block(string $block_name);
function end_block(string $block_name);
function render(string $template_name, array $data = []);

Examples

index.php, (*4)

assign('name', 'An');
echo $template->render('page.tpl');
```

layout.tpl
```html+php


  
    
    
    
<?php $this->block('title'); ?><?php $this->end_block('title'); ?></title>
  </head>
  <body>
  <?php $this->block('content'); ?>
  <?php $this->end_block('content'); ?>
  </body>
</html>

page.tpl ```html+php include('layout.tpl'); ?>, (*5)

block('title'); ?> Hello world! end_block('title'); ?>, (*6)

block('content'); ?>

block('content_title'); ?> Hello = $name ?>! end_block('content_title'); ?>

My first website! , (*8)

end_block('content'); ?>, (*7)


Final output ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Hello world!</title> </head> <body> <section class="section"> <div class="container"> <h1 class="title">Hello An!</h1> <p class="subtitle">My first website!</p> </div> </section> </body> </html>

The Versions

15/07 2018

dev-master

9999999-dev

A mini template engine for PHP

  Sources   Download

MIT

by anpham

15/07 2018

v1.0.1

1.0.1.0

A mini template engine for PHP

  Sources   Download

MIT

by anpham

19/06 2018

v1.0.0

1.0.0.0

A mini template engine for PHP

  Sources   Download

MIT

by anpham