2017 © Pedro Peláez
 

library view-presenter

A view helper system

image

nueve/view-presenter

A view helper system

  • Wednesday, December 27, 2017
  • by silentworks
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

View Presenter

Installation

It's recommended that you use Composer to install ViewPresenter., (*1)

composer require nueve/view-presenter

Usage

Initialize

$viewParser = new Nueve\ViewPresenter\PhpParser('template_directory_path');
$presentable = new Nueve\ViewParser\Presentable();
$view = new Nueve\ViewPresenter\View($viewParser, $presentable);

Now lets create a ViewPresenter., (*2)

 'Test Site',
            'site_description' => 'This is a test site to show how this works.'
        ];
    }
}
```

We can now make use of this by setting which template it should render for.

```php
$view->presenter('home', new SitePresenter());
```

Now when we render our home template the data from the presenter will be available.

```php
$view->render('home.php', [
    'developer' => 'Some Person'
]);
```

We now have access to all the properties of the `SitePresenter` in the home.php view file.

```php

=$site_name?></h1> <h2><?=$site_description?></h2> </header>

Hi =$developer?>, (*3)

Parsers

Out of the box only a single Parser is provided and that is for PHP, if you would like to add another Parser, you will need to implement the ParserInterface., (*4)

View

The Nueve\ViewPresenter\View class takes 3 arguments, the first is the ParserInterface, the second is a PresentableInterface class and the last is a config array., (*5)

The array only contain a single property at the moment and that is the file extension property file.ext, which is by default set to .php, you should change this if you decide to use a different Parser. e.g. Twig .twig., (*6)

The presenter method on the View object takes two params, the first can be a string or a array and the second should be a PresenterInterface., (*7)

Tests

To execute the test suite, you'll need phpunit., (*8)

$ phpunit

Credits

License

ViewPresenter is licensed under the MIT license. See License File for more information., (*9)

The Versions

27/12 2017

dev-master

9999999-dev

A view helper system

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

27/12 2017

0.2.0

0.2.0.0

A view helper system

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

29/12 2015

0.1.0

0.1.0.0

A view helper system

  Sources   Download

MIT

The Requires

  • php ^5.5

 

The Development Requires