2017 © Pedro Pelรกez
 

library templating

No-frills templating

image

stuartwakefield/templating

No-frills templating

  • Saturday, August 23, 2014
  • by stuartwakefield
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Templating

Build status, (*1)

Requires PHP 5.3+, (*2)

A super lightweight templating system that makes PHP templating awesome., (*3)

Basic usage

Starting with a really basic application which has the following layout:, (*4)

โ”œโ”€โ”€ templates
โ”‚   โ””โ”€โ”€ greeting.phtml
โ”œโ”€โ”€ composer.json
โ””โ”€โ”€ index.php

The composer.json file has stuartwakefield/templating in the the require map:, (*5)

{
    "require": {
        "stuartwakefield/templating": "0.1.0a"
    }
}

The template file templates/greeting.phtml has the following content:, (*6)

<p>Hey there, <?= $this->name ?>!</p>

The index.php script:, (*7)

fill(array(
    'name' => 'Bob'
));
echo $result; // 

Hey there, Bob!, (*8)

``` Simple as that! ## Presenters The really cool thing with this templating library is that you can start to use presenter objects with your templates effortlessly. Lets set up a basic presenter `src/Presenter.php` and lets assume you have set up composer to autoload the class: ```php name = $name; } function greet() { return 'Hello, ' . $name . '! You are logged in.'; } } ``` Then in a new template `templates/account.phtml`: ```php

= $this->greet() ?></p> , (*9)

Our updated index.php looks like this:, (*10)

<?php
require_once 'vendor/autoload.php';
use Templating\Template;

$template = new Template('templates/account.phtml');
$presenter = new Presenter('Khan');
$result = $template->fill($presenter);
echo $result; // 

Hello, Khan! You are logged in., (*11)

The Versions

23/08 2014

dev-master

9999999-dev http://templating.stuartw.io

No-frills templating

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

templating

23/08 2014

v0.1.1-alpha

0.1.1.0-alpha http://templating.stuartw.io

No-frills templating

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

templating

02/03 2014

v0.1.0-alpha

0.1.0.0-alpha

  Sources   Download

The Development Requires