-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
162 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
Lightweight PHP template engine | ||
=============================== | ||
|
||
Features | ||
-------- | ||
* Fast | ||
|
||
* Powerful | ||
|
||
* Easy | ||
|
||
Installing | ||
---------- | ||
|
||
@todo | ||
|
||
Getting started | ||
--------------- | ||
|
||
* Simple template: | ||
``` | ||
/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 | ||
// script.php | ||
use jmon\TplEngine\View; | ||
View::setBasePath('/base/path'); | ||
View::set('title', 'hello world!'); | ||
echo View::render('simple-template.phtml'); | ||
?> | ||
``` | ||
``` | ||
<!-- 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 | ||
``` | ||
``` | ||
<!-- 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> | ||
``` | ||
``` | ||
<!-- home/index.phtml --> | ||
<?php \jmon\TplEngine\View::templateExtend('layout.phtml')?> | ||
<h1><?= \jmon\TplEngine\View::get('title') ?></h1> | ||
``` | ||
``` | ||
<?php | ||
// script.php | ||
use jmon\TplEngine\View; | ||
View::setBasePath('/base/path'); | ||
View::set('title', 'hello world!'); | ||
echo View::render('/home/index.phtml'); | ||
?> | ||
``` | ||
``` | ||
<!-- 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 | ||
``` | ||
``` | ||
<!-- 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> | ||
``` | ||
``` | ||
<!-- partial.phtml --> | ||
<footer><?= \jmon\TplEngine\View::get('footer-text') ?></footer> | ||
``` | ||
``` | ||
<?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'); | ||
?> | ||
``` | ||
``` | ||
<!-- final rendering --> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>hello world!</title> | ||
</head> | ||
<body> | ||
<h1>hello world!</h1> | ||
<footer>Awesome footer!</footer> | ||
</body> | ||
</html> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php echo \jmon\TplEngine\View::get('varname') ?> | ||
<?= \jmon\TplEngine\View::get('varname') ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1<?php echo \jmon\TplEngine\View::content() ?>1 | ||
1<?= \jmon\TplEngine\View::content() ?>1 |
This file was deleted.
Oops, something went wrong.