2017 © Pedro Peláez
 

library template

Templating library

image

lucid/template

Templating library

  • Sunday, August 28, 2016
  • by iwyg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Templating library

Author Source Code Software License, (*1)

Build Status Code Coverage HHVM, (*2)

An extendable templating library for php., (*3)

Requirements

php >= 5.6

Installation

$ composer require lucid/template

Getting started

render('partials/content.php', ['title' => 'Hello World!']);

```

## Partials

### Inserts

```php

    

    
$view->insert('partials/footer.php'); $view->insert('partials/content.php'); $view->insert('partials/footer.php');
``` ### Extending existing templates The templates `partials/content.php`: ```php = $view->extend('master.php') ?> = $view->section('content') ?> <p>Extended content</p> = $view->endsection() ?>

master.php:, (*4)

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title><?= $title ?></title>
  </head>
  <body>
    <div id="main">
      <?= $view->section('content') ?>
        <p>The default content.</p>
      <?= $view->endsection() ?>
    </div>
  </body>
</html>

Sections

Tempalte Listeners

Adding template listeners can be usefull if you want to add data to a specific template. This data my be derieved from any resource you may want (e.g. DB, Container, etc)., (*5)

<?php

$view->addListener('head.php', new RenderHeadListener($headerData));

Your listener may look something like this, (*6)

<?php

use Lucid\Template\Listener\ListenerInterface;

class RenderHeadListener implements ListenerInterface
{
    private $data;

    public function __construct(array $headerData)
    {
        $this->data = $data;
    }

    public function onRender(TemplateDataInterface $data)
    {
        // add header data to `$data`
    }
}

The Versions

28/08 2016

dev-develop

dev-develop

Templating library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar iwyg

templating

12/04 2016

dev-master

9999999-dev

Templating library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar iwyg

templating

12/04 2016

v0.0.1

0.0.1.0

Templating library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Avatar iwyg

templating