Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Maslosoft Miniview

Mini view is minimal template rendering library based on Yii controller renderer

Latest Stable Version License [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Maslosoft/Miniview/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Maslosoft/Miniview/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/Maslosoft/Miniview/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Maslosoft/Miniview/?branch=master)

Quick Install

composer require maslosoft/miniview

Usage

This is some example widget using MiniView:

namespace Company\SomeNamespace;

use Maslosoft\MiniView\MiniView;

class MyWidget
{

	/**
	 * View renderer
	 * @var MiniView
	 */
	public $view = null;
	
	/**
	 * @var string
	 */
	public $version = '';

	public function __construct()
	{
		$this->view = new MiniView($this);
		$this->version = $this->view->getVersion();
	}

	public function show()
	{
		return $this->view->render('myView', ['user' => 'Joe'], true);
	}

	public function greet($name)
	{
		return "Nice to meet you $name!" . PHP_EOL;
	}
}

In view file, all widget public properties as well as methods are available using $this. View file is located in folder views located in same folder as widget class.

Example view file:

Hello <?= $user ?>!
<?= $this->greet($user);?>
The version is <?= $this->version;?>

Calling show() will return rendered view file located in classFolder/views/myView.php with variable $user with value Joe.

use Company\SomeNamespace\MyWidget;

require __DIR__ . '/../src/Miniview.php';
require __DIR__ . '/MyWidget.phps';

$widget = new MyWidget;

echo $widget->show();

Run example

Go to examples folder and type php run.php

About

Mini view is minimal template rendering library

Topics

Resources

License

Packages

No packages published