2017 © Pedro Peláez
 

windwalker-package view

Windwalker View package

image

windwalker/view

Windwalker View package

  • Friday, February 12, 2016
  • by asika32764
  • Repository
  • 3 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

Windwalker View

Installation via Composer

Add this to the require block in your composer.json., (*1)

``` json { "require": { "windwalker/view": "~2.0" } }, (*2)


## Create A Simple View ### AbstractView `AbstractView` is very simple, it only need a render method to render what you want. ``` php use Windwalker\View\AbstractView; class MyView extends AbstractView { public function render() { $tmpl = <<<TMPL # The is a Markdown Article Hello %s~~~! TMPL; return MyMarkdown::render(sprintf($tmpl, $this->data['foo'])); } } // Create view and set data $view = new MyView; $view->set('foo', 'World'); $view->render();

The Result will be:, (*3)

``` html, (*4)

The is a Markdown Article

Hello World~~~!, (*5)


### SimpleHtmlView `SimpleHtmlView` can set a php file to render: ``` php use Windwalker\View\SimpleHtmlView; class MyHtmlView extends SimpleHtmlView { public function prepare($data) { // Format dome data $data['time'] = $data['time']->format('Y-m-d H:i:s'); $data['link'] = '/flower/' . OutputFilter::stringUrlSafe($data['name']) . '.html'; } } $view = new MyHtmlView; $view->set('time', new DateTime); $view->set('name', $name); $view->setLayout('/path/to/template.php')->render();

The template file:, (*6)

``` php , (*7)

Now is: escape($time); ?> I'm: escape($data['name']); ?> , (*8)


## HtmlView `HtmlView` is more powerful than `SimpleHtmlView`, we can set [Renderer](https://github.com/ventoviro/windwalker-renderer) as a render engine into it, and find template in several paths. ``` php use Windwalker\View\HtmlView; $paths = new SplPriorityQueue; $paths->insert('path/of/system', 300); $paths->insert('path/of/theme', 500); $data = array( 'time' => new DateTime ); $view = new HtmlView($data, new PhpRenderer($paths)); $view->setLayout('foo')->render(); // Will find foo.php in every paths.

See also: Windwalker Renderer, (*9)

Extends It

``` php use Windwalker\View\HtmlView; use Windwalker\Renderer\BladeRenderer;, (*10)

// A Blade View class BladeHtmlView extends HtmlView { public function __construct($data = array(), BladeRenderer $renderer = null) { $renderer = $renderer ? : new BladeRenderer('default/path', array('cache_path' => 'cache/path')), (*11)

    parent::__construct($data, $renderer);
}

}, (*12)

// View for different MVC structures class ArticleHtmlView extends BladeHtmlView { public function prepare($data) { $data['time'] = $data['time']->format('Y-m-d H:i:s'); } }, (*13)

$view = new MyHtmlView;, (*14)

$view->['time'] = new DateTime; // Use array access, (*15)

$view->setLayout('template')->render(); // Will find template.blade.php, (*16)


### The Data object HtmlView use `Windwalker\Data\Data` as data store, we don't need to worry about data exists or not. ``` php <?php $time = $data['time']; // Exists $name = $data['name']; // Not exists, just return null. $title = $data->title; // Also support object access.

See Windwalker Data, (*17)

JsonView

JsonView use Registry as data store, we can separate different level by dot(.)., (*18)

``` php $view = new JsonView;, (*19)

$view['foo.bar'] = 'baz';, (*20)

$view->render();, (*21)


The result will be: ``` json { "foo": { "bar": "baz" } }

The Versions

12/02 2016

dev-master

9999999-dev https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

12/02 2016

dev-test

dev-test https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

12/02 2016

2.1.7

2.1.7.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

12/02 2016

2.1.8

2.1.8.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

12/02 2016

2.1.9

2.1.9.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

11/08 2015

2.1

2.1.0.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

11/08 2015

2.1.1

2.1.1.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

11/08 2015

2.1.2

2.1.2.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

11/08 2015

2.1.4

2.1.4.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

11/08 2015

2.1.5

2.1.5.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

11/08 2015

2.1.6

2.1.6.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

27/07 2015

2.0.9

2.0.9.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.0

2.0.0.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.1

2.0.1.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.2

2.0.2.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.3

2.0.3.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.4

2.0.4.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.5

2.0.5.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.6

2.0.6.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.7

2.0.7.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

16/12 2014

2.0.8

2.0.8.0 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

25/11 2014

2.0.0-beta2

2.0.0.0-beta2 https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

LGPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker

05/10 2014

2.0.0-alpha

2.0.0.0-alpha https://github.com/ventoviro/windwalker-view

Windwalker View package

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.10

 

The Development Requires

framework view windwalker