2017 © Pedro Peláez
 

library views

A simple PHP templating engine

image

vakata/views

A simple PHP templating engine

  • Thursday, October 27, 2016
  • by vakata
  • Repository
  • 1 Watchers
  • 0 Stars
  • 43 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

views

Latest Version on Packagist ![Software License][ico-license] Build Status Code Climate ![Tests Coverage][ico-cc-coverage], (*1)

A simple PHP templating engine., (*2)

Install

Via Composer, (*3)

``` bash $ composer require vakata/views, (*4)


## Usage ``` php use vakata\views\Views; $views = new vakata\views\Views(); // register template dirs $views->dir('/path/to/templatedir'); $views->dir('/path/to/otherdir', 'other'); // a variable available in all templates $views->share("siteTitle", "test"); // variables available in all templates $views->share(["a" => 1, "b" => 2]); // render a template from the first dir: $views->render('profile', ['user' => 'Test']); // render a template from a named dir: $views->render('other::user', ['user' => 'Test']); // the above is the same as $v = $views->get('other::user'); $v->render(['user'=>'Test']);

A sample template may look like this:, (*5)

layout('master.layout', ['masterParam' => 'master-value']); ?>

Content

sectionStart("sidebar"); ?>
Here is some unfiltered content: = $b ?> 
Here is some filtered content: = $this->e($user) ?> 
sectionStop(); ?>

Here is some filtered and transformed content:
= $this->e($user, 'trim|strtouuper') ?> 

Include a child template:
= $this->insert('nameddir::include', ['optional' => 'params']); ?>

As for the master template (which can in turn have its own master template):, (*6)

I am master!

= $this->section("sidebar") ?>

= $masterParam ?> = $a ?>

The unnamed part of the above template:
= $this->section() ?>

Read more in the API docs, (*7)

Testing

bash $ composer test, (*8)

Contributing

Please see CONTRIBUTING for details., (*9)

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

27/10 2016

dev-master

9999999-dev https://github.com/vakata/views

A simple PHP templating engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

views vakata

27/10 2016

2.0.2

2.0.2.0 https://github.com/vakata/views

A simple PHP templating engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

views vakata

07/08 2016

2.0.1

2.0.1.0 https://github.com/vakata/views

A simple PHP templating engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

views vakata

07/08 2016

2.0.0

2.0.0.0 https://github.com/vakata/views

A simple PHP templating engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

views vakata

14/04 2016

1.0.1

1.0.1.0 https://github.com/vakata/views

A simple PHP templating engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

views vakata

13/01 2016

1.0.0

1.0.0.0 https://github.com/vakata/views

A simple PHP templating engine

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

views vakata