定制 nueve/view-presenter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nueve/view-presenter

Composer 安装命令:

composer require nueve/view-presenter

包简介

A view helper system

README 文档

README

Installation

It's recommended that you use Composer to install ViewPresenter.

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.

<?php

class SitePresenter implements \Nueve\ViewPresenter\PresenterInterface
{
    public function data()
    {
        return [
            'site_name' => '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.

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

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

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

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

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

<p>Hi <?=$developer?></p>

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.

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.

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.

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.

Tests

To execute the test suite, you'll need phpunit.

$ phpunit

Credits

License

ViewPresenter is licensed under the MIT license. See License File for more information.

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固