Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romanzaycev/tooolooop
PHP7 lightweight native template engine
https://github.com/romanzaycev/tooolooop
php7 template template-engine templating
Last synced: about 1 month ago
JSON representation
PHP7 lightweight native template engine
- Host: GitHub
- URL: https://github.com/romanzaycev/tooolooop
- Owner: romanzaycev
- License: mit
- Created: 2017-12-09T15:23:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-26T16:12:13.000Z (almost 3 years ago)
- Last Synced: 2024-10-14T04:21:41.885Z (3 months ago)
- Topics: php7, template, template-engine, templating
- Language: PHP
- Size: 54.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Tooolooop
---
[![Build status][travis-image]][travis-url] [![Code coverages][codecov-image]][codecov-url] [![Code climate][codeclimate-image]][codeclimate-url] [![Latest Stable Version](https://poser.pugx.org/romanzaycev/tooolooop/v/stable)](https://packagist.org/packages/romanzaycev/tooolooop) [![Total Downloads](https://poser.pugx.org/romanzaycev/tooolooop/downloads)](https://packagist.org/packages/romanzaycev/tooolooop)PHP7 lightweight native templates.
## Installation
via Composer:
```bash
composer require romanzaycev/tooolooop
```## Usage
```php
make('page');
$template->assign(['text' => 'Lorem ipsum']);echo $template->render();
````views/page.php`:
```html
extend('layout') ?>=$this->e($text)?>
start('footer') ?>
Some footer content.
end() ?>
````views/layout.php`:
```htmlExample
Example
=$this->block('content')?>
=$this->block('footer')?>
```
Need more [examples](https://github.com/romanzaycev/tooolooop/tree/master/example)?
## Requires
PHP >= 7.2.0
## Extending library
### PSR-11 container support
You can use a PSR-11 compatible
container and inject dependencies into objects
that are generated inside the library (Scope):```php
setContainer($container);
$template = $engine->make('page'); // <-- Scope in this template will be obtained from container
```You can define the implementation of `Romanzaycev\Tooolooop\Scope\ScopeInterface` in the
container configuration and engine instances Scope through it.⚠️ ATTENTION! Make sure that the container returns a new instance of Scope all time! Cached Scope instance does not work.
### User scope
Otherwise, you can specify a custom implementation of the class via `$engine->setScopeClass()`:
```php
setScopeClass(UserSpecificScope::class);
```## Testing
```bash
composer run test
```[travis-image]: https://travis-ci.org/romanzaycev/tooolooop.svg?branch=master
[travis-url]: https://travis-ci.org/romanzaycev/tooolooop[codecov-image]: https://codecov.io/gh/romanzaycev/tooolooop/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/romanzaycev/tooolooop[codeclimate-image]: https://api.codeclimate.com/v1/badges/d36f92834ead870f1fbe/maintainability
[codeclimate-url]: https://codeclimate.com/github/romanzaycev/tooolooop/maintainability