Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anovsiradj/php-cutter
flexible template library
https://github.com/anovsiradj/php-cutter
composer php php-library php5 php7 template-library
Last synced: 24 days ago
JSON representation
flexible template library
- Host: GitHub
- URL: https://github.com/anovsiradj/php-cutter
- Owner: anovsiradj
- License: mit
- Created: 2016-10-26T09:40:15.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T14:00:15.000Z (over 6 years ago)
- Last Synced: 2024-04-25T07:43:17.979Z (7 months ago)
- Topics: composer, php, php-library, php5, php7, template-library
- Language: PHP
- Homepage: https://git.io/vhz7U
- Size: 28.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cutter
Flexible Template Library. Inspired by Blade (Laravel) and Twig (Symfony).
Tested on PHP `5.6`, `~7` and `~8`.
## Installation
[Download this source](/anovsiradj/php-cutter/releases) or via [Composer](https://packagist.org/packages/anovsiradj/cutter):
```cmd
composer require anovsiradj/cutter
```## Example
`/index.php`
```php
require 'Cutter.php'; // directly or composer$cutter = new anovsiradj\Cutter;
$cutter->set('layout','/layouts/main');$cutter->data('page_title', 'My Posts'); // set variable
$cutter->view(
'/pages/home',
['date_today' => date('Y-m-d')], // set variable(s)
);
````/layouts/main.php`
use `section()` to define section
```php
= $page_title ?>
section('content') ?>
section('script') ?>
```
`/pages/home.php`
use `begin()` and `end()` to output-buffer section
```php
begin('content') ?>
- Post title 1
- Post title 2
- Post title 3
end() ?>begin('script') ?>
alert('date today is <?php echo $date_today ?>')
end() ?>
```for more, see `/example/`.
## Reference
**Class Methods**
```php
get( $key ) : void;
set( $key, mixed $val ) : void;data( mixed $any [, mixed $val] ): mixed;
load( $file [, bool $isob = false] ): void;
view( mixed $name [, array $data = [] [, bool $render = true ] ] ) : void;
render( [array $data = [] ] ) : void;
section( $name ) : bool;
begin( $name ) : void;
end(): void
```## Development
TODO:
- single file library / phar?
- inheritance
- ~~dynamic path~~
- ~~dynamic view~~All suggestions are welcome. Thanks.
## Reference
- https://laravel.com/docs/5.8/blade
- https://twig.symfony.com/doc/2.x/