https://github.com/esase/tiny-view
The simple template engine for representation of your html code.
https://github.com/esase/tiny-view
esase framework html layout lightweight microservices renderer templateengine tinyframework view
Last synced: 3 months ago
JSON representation
The simple template engine for representation of your html code.
- Host: GitHub
- URL: https://github.com/esase/tiny-view
- Owner: esase
- License: mit
- Created: 2020-08-19T09:50:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-22T10:28:42.000Z (over 5 years ago)
- Last Synced: 2025-11-27T14:56:09.485Z (4 months ago)
- Topics: esase, framework, html, layout, lightweight, microservices, renderer, templateengine, tinyframework, view
- Language: PHP
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tiny-view
[](https://travis-ci.com/github/esase/tiny-view/builds)
[](https://coveralls.io/github/esase/tiny-view?branch=master)
**Tiny/View** separates your business logic from its representation, it means you can store your `view` as a list of
separated `.phtml` files and pass there you data keeping you controllers clean.
The package is very small and fast due to using native `php` inside templates and layouts, yes we don't use
any extra markup language, it's only relies on the php's [alternative syntax](https://www.php.net/control-structures.alternative-syntax)
There are only two main entities: `templates` and `layouts`.
`Templates` are used for displaying small peaces of information like list of users, a login form, etc. And the `layouts` which
work as wrappers for those templates. For instance you can have several layouts with already included `css` and `js` files and
It makes you life easier because you don't need to specify any `js` and `css` files for every template.
## Template
```php
[ // an array of users
['id' => 1, 'name' => 'Tester1'],
['id' => 2, 'name' => 'Tester2']
]],
'./users.phtml', // a template for the data,
'./layout/base.phtml' // a layout it's optional
);
// render the template using passed variables and wrap its content to a layout
echo $view;
```
```html
-
= $this->id ?>: = $this->name ?>
users as $user): ?>
```
## Layout
```html
My test site
= $this->content ?>
```
## View helpers
When it's not enough a pre built functionality or it might be not convenient way to work with templates
you can register you own list of helpers (small functions) which will do exactly you want. Please read more information in the documentation
## Installation
Run the following to install this library:
```bash
$ composer require esase/tiny-view
```
## Documentation
https://tiny-docs.readthedocs.io/en/latest/tiny-view/docs/index.html