2017 © Pedro Peláez
 

library zaplate

A pseudo-template engine.

image

bfitech/zaplate

A pseudo-template engine.

  • Tuesday, May 9, 2017
  • by rendra
  • Repository
  • 1 Watchers
  • 0 Stars
  • 261 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 10 % Grown

The README.md

zaplate

PHP is an HTML template engine. This only sugars it up a bit, enough to render mostly-static HTML, which is all zap* ever needs due to it being RESTful-oriented., (*1)

Use other full-blown templating engines for rendering complex dynamic HTML., (*2)

Latest Stable Version Latest Unstable Version Build Status Codecov GitHub license, (*3)


Installation

Install it from Packagist:, (*4)

$ composer -vvv require bfitech/zaplate

Sample Usage

template.php

<p><?php echo $group ?></p>
<ul>
    <?php foreach ($members as $member): ?>
    <li><?php echo $member ?></li>
    <?php endforeach; ?>
</ul>

renderer.php

<?php

require __DIR__ . '/vendor/autoload.php';

class Filter {
    public function whoami($name) {
        if (is_string($name))
            return $name;
        return array_map(function($iname){
            if (stripos($iname, 'jekyll') !== false)
                return 'Mr Hyde';
            return $iname;
        }, $name);
    }
}

BFITech\ZapTemplate\Template::load('template.php', [
    'group' => "Extraordinary Gents",
    'members' => [
        'Allan Quatermain',
        'Henry Jekyll',
    ],
], [
    [(new Filter), 'whoami'],
]);

Run it:, (*5)

$ php renderer.php
<p>Extraordinary Gents</p>
<ul>
    <li>Allan Quatermain</li>
    <li>Mr Hyde</li>
</ul>

PROTIP: If you want to minify the HTML on production, run your template file through ~~your~~my favorite minifier prior to rendering it, e.g.:, (*6)

$ [ ! -f template.orig.php ] && cp template.{,orig.}php
$ php -w template.orig.php | \
> html-minifier \
>   --collapse-whitespace \
>   --trim-custom-fragments > \
> template.php

Aaand ... huzzah!, (*7)

$ php renderer.php
<p>Extraordinary Gents</p><ul><li>Allan Quatermain</li><li>Mr Hyde</li></ul>

Documentation

Documentation available with:, (*8)

$ doxygen
$ x-www-browser docs/html/index.html

The Versions

09/05 2017

dev-master

9999999-dev

A pseudo-template engine.

  Sources   Download

MIT

The Requires

  • php >=5.5 || ~7.0

 

The Development Requires

by Rendra Suroso

09/05 2017

1.3.1

1.3.1.0

A pseudo-template engine.

  Sources   Download

MIT

The Requires

  • php >=5.5 || ~7.0

 

The Development Requires

by Rendra Suroso

19/04 2017

1.3.0

1.3.0.0

A pseudo-template engine.

  Sources   Download

MIT

The Requires

  • php >=5.5 || ~7.0

 

The Development Requires

by Rendra Suroso

06/04 2017

1.2.0

1.2.0.0

A pseudo-template engine.

  Sources   Download

MIT

The Requires

  • php >=5.5 || ~7.0

 

The Development Requires

by Rendra Suroso

29/03 2017

1.0.1

1.0.1.0

A pseudo-template engine.

  Sources   Download

MIT

The Requires

  • php >=5.5 || ~7.0

 

The Development Requires

by Rendra Suroso

07/03 2017

1.0.0

1.0.0.0

A pseudo-template engine.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Rendra Suroso