library viewengine
Lightweight php template engine system
jmon/viewengine
Lightweight php template engine system
- Friday, August 21, 2015
- by joan-mon
- Repository
- 1 Watchers
- 0 Stars
- 10 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 0 % Grown
Lightweight PHP template engine
Features
-
Fast, (*1)
-
Powerful, (*2)
-
Easy, (*3)
Installing
@todo, (*4)
Getting started
/base/path/|
|_ simple-template.phtml
|_ script.php
<!-- simple-template.phtml -->
<!DOCTYPE html>
<html>
<head>
<title><?= \jmon\TplEngine\View::get('title') ?></title>
</head>
<body>
<h1><?= \jmon\TplEngine\View::get('title') ?></h1>
</body>
</html>
```php
<?php
// script.php
use jmon\TplEngine\View;
View::setBasePath('/base/path');
View::set('title', 'hello world!');
echo View::render('simple-template.phtml');
?>
```html
<!-- final rendering -->
<!DOCTYPE html>
<html>
<head>
<title>hello world!</title>
</head>
<body>
<h1>hello world!</h1>
</body>
</html>
* Template with layout:
/base/path/|
|_ layout.phtml
|_ home/index.phtml
|_ script.php
```html
<!-- layout.phtml -->
<!DOCTYPE html>
<html>
<head>
<title><?= \jmon\TplEngine\View::get('title') ?></title>
</head>
<body>
<!-- Place where will be rendered the content of templates that extends this one -->
<?= \jmon\TplEngine\View::content() ?>
</body>
</html>
```html
<!-- home/index.phtml -->
<?php \jmon\TplEngine\View::templateExtend('layout.phtml')?>
<h1><?= \jmon\TplEngine\View::get('title') ?></h1>
```php
<?php
// script.php
use jmon\TplEngine\View;
View::setBasePath('/base/path');
View::set('title', 'hello world!');
echo View::render('/home/index.phtml');
?>
```html
<!-- final rendering -->
<!DOCTYPE html>
<html>
<head>
<title>hello world!</title>
</head>
<body>
<h1>hello world!</h1>
</body>
</html>
* Use of partial:
/base/path/|
|_ template.phtml
|_ partial.phtml
|_ script.php
```html
<!-- template.phtml -->
<!DOCTYPE html>
<html>
<head>
<title><?= \jmon\TplEngine\View::get('title') ?></title>
</head>
<body>
<h1><?= \jmon\TplEngine\View::get('title') ?></h1>
<?php \jmon\TplEngine\View::partial('partial.phtml')?>
</body>
</html>
```html
<!-- partial.phtml -->
<footer><?= \jmon\TplEngine\View::get('footer-text') ?></footer>
```php
<?php
// script.php
use jmon\TplEngine\View;
View::setBasePath('/base/path');
View::set('title', 'hello world!');
View::set('footer-text', 'Awesome footer!');
echo View::render('template.phtml');
?>
```html
<!-- final rendering -->
<!DOCTYPE html>
<html>
<head>
<title>hello world!</title>
</head>
<body>
<h1>hello world!</h1>
<footer>Awesome footer!</footer>
</body>
</html>
dev-master
9999999-dev
Lightweight php template engine system
Sources
Download
MIT
The Requires
The Development Requires
template
php
engine
view
1.0.0
1.0.0.0
Lightweight php template engine system
Sources
Download
MIT
The Requires
The Development Requires
template
php
engine
view