PHP Classes

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
2024-03-23 (10 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 49 This week: 1All time: 10,662 This week: 350Up
Version License PHP version Categories
intpl 1.1.3Artistic 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. <contact>
Classes: 17 packages by
Country: Greece Greece
Innovation award
Innovation award
Nominee: 7x

Winner: 2x

Example

<?php

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

include(
ROOT . '/../src/InTpl.php');

echo
InTpl::Tpl('tpl3.php', ROOT)->render();


Details

InTpl

Simple PHP templates supporting Template Inheritance.

see also:

  • ModelView a simple, fast, powerful and flexible MVVM framework for JavaScript
  • tico a tiny, super-simple MVC framework for PHP
  • LoginManager a simple, barebones agnostic login manager for PHP, JavaScript, Python
  • SimpleCaptcha a simple, image-based, mathematical captcha with increasing levels of difficulty for PHP, JavaScript, Python
  • Dromeo a flexible, and powerful agnostic router for PHP, JavaScript, Python
  • PublishSubscribe a simple and flexible publish-subscribe pattern implementation for PHP, JavaScript, Python
  • Importer simple class &amp; dependency manager and loader for PHP, JavaScript, Python
  • Contemplate a fast and versatile isomorphic template engine for PHP, JavaScript, Python
  • HtmlWidget html widgets, made as simple as possible, both client and server, both desktop and mobile, can be used as (template) plugins and/or standalone for PHP, JavaScript, Python (can be used as plugins for Contemplate)
  • Paginator simple and flexible pagination controls generator for PHP, JavaScript, Python
  • Formal a simple and versatile (Form) Data validation framework based on Rules for PHP, JavaScript, Python
  • Dialect a cross-vendor &amp; cross-platform SQL Query Builder, based on GrammarTemplate, for PHP, JavaScript, Python
  • DialectORM an Object-Relational-Mapper (ORM) and Object-Document-Mapper (ODM), based on Dialect, for PHP, JavaScript, Python
  • Unicache a simple and flexible agnostic caching framework, supporting various platforms, for PHP, JavaScript, Python
  • Xpresion a simple and flexible eXpression parser engine (with custom functions and variables support), based on GrammarTemplate, for PHP, JavaScript, Python
  • Regex Analyzer/Composer Regular Expression Analyzer and Composer for PHP, JavaScript, Python

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', [VIEWS])->render([/../]);

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:49
This week:1
All time:10,662
This week:350Up