InTpl PHP Template Engine Inheritance: Render templates that inherit from other templates

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-09-15 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 35 This week: 1All time: 9,990 This week: 232Up
Version License PHP version Categories
intpl 1.0Artistic License5PHP 5, Templates
Description Author

This class can render templates that inherit from other templates.

It can take a template file that is a PHP script contains HTML mixed with PHP code with template commands and executes the script to render the template output.

Template PHP scripts can inherit from other templates using a call to this class to include other base template PHP scripts.

Picture of Nikos M.
Name: Nikos M. is available for providing paid consulting. Contact Nikos M. .
Classes: 9 packages by
Country: Greece Greece
Age: 44
All time rank: 112611 in Greece Greece
Week rank: 1 Up
Innovation award
Innovation award
Nominee: 4x

Details

InTpl

Simple PHP templates supporting Template Inheritance.

Example:

[VIEWS]/layout/base.tpl.php:

<!DOCTYPE html>
<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?php $this->start('title'); ?>No Title<?php $this->end('title'); ?></title>

</head><body>
<?php $this->start('content'); ?>
No Content
<?php $this->end('content'); ?>
</body></html>

[VIEWS]/index.tpl.php:

<?php $this->extend('layout/base.tpl.php'); ?>

<?php $this->start('title'); ?>Index<?php $this->end('title'); ?>

<?php $this->start('content'); ?>
<p>Index page</p>
<?php $this->end('content'); ?>

driver code:

<?php

define('VIEWS', dirname(__FILE__));

include(VIEWS . '/InTpl.php');

echo InTpl::Tpl('index.tpl.php', array(VIEWS))->render(array(/../));

output:

<!DOCTYPE html>
<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Index</title>

</head><body>
<p>Index page</p>
</body></html>
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetest (5 files)
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  src  
File Role Description
  Plain text file InTpl.php Class Class source

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file out Output Processed template output
  Accessible without login Plain text file test.php Example Example script
  Accessible without login Plain text file tpl1.php Data Template script
  Accessible without login Plain text file tpl2.php Data Template script
  Accessible without login Plain text file tpl3.php Data Template script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:35
This week:1
All time:9,990
This week:232Up

For more information send a message to info at phpclasses dot org.