Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/isruslan/php-template
Simple PHP template class.
https://github.com/isruslan/php-template
Last synced: 3 months ago
JSON representation
Simple PHP template class.
- Host: GitHub
- URL: https://github.com/isruslan/php-template
- Owner: isRuslan
- Created: 2013-09-03T05:09:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-02-21T08:05:55.000Z (almost 7 years ago)
- Last Synced: 2024-04-14T19:48:29.457Z (9 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 19
- Watchers: 6
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# php-template
Simple PHP template class.
## Create template file
[Example](https://github.com/isRuslan/php-template/blob/master/tpl.html)
Template variables:
- `{var}` - single variable
- `{loop items} {name} {end loop}` - loop for items array
- `{%index%}` - index of item in items loop## Create index.php file
[Example](https://github.com/isRuslan/php-template/blob/master/index.php)
- Include template class:
`include 'template.php';`
- Create an object:
`$template = new Template();`
- Set template variables, single:
`$template->assign( 'my_var', 'test' );`
- Set template variables, loops:
`$template->assign( 'items', array( array( 'name' => 'First' ), array( 'name' => 'Second' ) ) );`
- Parse template:
`$template->parse( 'tpl.html' );`