Skip to content

dlundgren/phrender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phrender

Travis CI Code Climate

Phrender is a simplistic PHP renderer that provides a no frills rendering engine.

PSR-1 and PSR-4 compliant.

This uses the Output Interop specification.

Contexts

The following contexts are provided for use:

  • Collection Any number of the following
  • Any Matches any template
  • Contains uses stripos to match the template
  • Match Uses a regex to match the template
  • Only Will match only the specified template

Installation

Phrender can be installed using composer

composer require dlundgren/phrender

Basic Usage

<?php

$factory = new Phrender\Template\Factory(['/path/to/views']);
$engine = new Phrender\Engine($factory, new Phrender\Context\Collection());

// index.php: <?= $this->var ?>

// output = "something"
$output = $engine->render('index', ['var' => 'something']); 

// Alternate
// output = ""
$ctxt   = new Phrender\Context\Contains('something', ['var' => 'display']);
$output = $engine->render('index', $ctxt); 

Different extension

You may use an alternate extension for the templates with the Template Factory constructor second argument.

$factory = new Phrender\Template\Factory(['/path/to/views'], 'phtml');
$engine = new Phrender\Engine($factory, new Phrender\Context\Collection());

// index.phtml: <?= $this->var ?>

// output = "something"
$output = $engine->render('index', ['var' => 'something']);