2017 © Pedro Pelรกez
 

library views

Simple View Renderer

image

cesarv/views

Simple View Renderer

  • Wednesday, April 1, 2015
  • by cesarv
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Views

A simple view renderer - will read a .phtml file from the directory passed to the views.dir option, bind variables to it, and return the content as a string., (*1)

NO HEAVY TEMPLATE ENGINE! - PHP does templating on it's own, remember?, (*2)

Options

The following options are avaliable during object construction:, (*3)

Option Description Required
views.dir Root path of your views directory. Yes

Usage

Consider the following directory structure:, (*4)

app/
โ”œโ”€โ”€ index.php
โ”œโ”€โ”€ vendor
โ”‚ย ย  โ””โ”€โ”€ autoload.php
โ””โ”€โ”€ views
    โ””โ”€โ”€ Hello.phtml

Hello.phtml contains the following:, (*5)

<!doctype html>
<html>
    <head>
        <title>Hello</title>
    </head>
    <body>
        <p>Hello <?= $name ?></p>
    </body>
</html>

This is how we render our view from index.php:, (*6)

<?php require 'vendor/autoload.php';

$views = new \CesarV\Views\View(array(
    'views.dir' => __DIR__ . '/views'
));

echo $views->render('hello', array('name' => 'Cesar'));

Notice that array('name' => 'Cesar') became $name in Hello.phtml?, (*7)

The Versions

01/04 2015

dev-master

9999999-dev https://github.com/cesar-v/views

Simple View Renderer

  Sources   Download

MIT

view views

01/04 2015

v1.0.0

1.0.0.0 https://github.com/cesar-v/views

Simple View Renderer

  Sources   Download

MIT

view views