2017 © Pedro Peláez
 

library cutter

(another) PHP Template Library

image

anovsiradj/cutter

(another) PHP Template Library

  • Tuesday, July 24, 2018
  • by anovsiradj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 42 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 100 % Grown

The README.md

Cutter

Flexible Template Library. Inspired by Blade (Laravel) and Twig (Symfony)., (*1)

Tested on PHP 5.6, ~7 and ~8., (*2)

Installation

Download this source or via Composer:, (*3)

composer require anovsiradj/cutter

Example

/index.php, (*4)

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, (*5)

use section() to define section, (*6)

<!DOCTYPE html>
<html>
    <head>
        <title><?= $page_title ?></title>
    </head>

    <body>
        <div>
            <?php $cutter->section('content') ?>
        <div>

        <?php $cutter->section('script') ?>
    </body>
</html>

/pages/home.php, (*7)

use begin() and end() to output-buffer section, (*8)

begin('content') ?>


  • Post title 1
  • Post title 2
  • Post title 3
end() ?> begin('script') ?> end() ?>

for more, see /example/., (*9)

Reference

Class Methods, (*10)

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~~, (*11)

All suggestions are welcome. Thanks., (*12)

Reference

  • https://laravel.com/docs/5.8/blade
  • https://twig.symfony.com/doc/2.x/

The Versions

24/07 2018

dev-master

9999999-dev

(another) PHP Template Library

  Sources   Download

MIT

The Requires

  • php >=5

 

by Avatar anovsiradj

24/07 2018

3.0.0

3.0.0.0

(another) PHP Template Library

  Sources   Download

MIT

The Requires

  • php >=5

 

by Avatar anovsiradj

18/06 2018

2.0.1

2.0.1.0

(another) PHP Template Library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Avatar anovsiradj

02/06 2018

2.0.0

2.0.0.0

(another) PHP Template Library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Avatar anovsiradj

20/12 2016

v1.1

1.1.0.0

(another) PHP Template Library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Avatar anovsiradj

24/11 2016

v1.0

1.0.0.0

(another) PHP Template Library

  Sources   Download

MIT

by Avatar anovsiradj