habanero/puke

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v0.2) of this package.

Lambda-based template system for PHP

v0.2 2012-12-29 12:50 UTC

This package is auto-updated.

Last update: 2020-01-29 20:55:51 UTC


README

Many years ago CoffeeKup was born, we have lots of template engines now.

Well, I made this just for the "why not?" and inspired by the Markaby pattern, actually less sexy on PHP.

Of course, shall be installed as dependency using the Composer.

Basic usage

Display your favorite books.

<?php

require 'vendor/autoload.php';

$data = [
  [
    'author' => 'Hernando de Soto',
    'title' => 'The Mystery of Capitalism'
  ],
  [
    'author' => 'Henry Hazlitt',
    'title' => 'Economics in One Lesson'
  ],
  [
    'author' => 'Milton Friedman',
    'title' => 'Free to Choose'
  ],
];

# painless
$view = function () {
  if ($books) {
    table(function () {
      tr(function () {
        th('Author');
        th('Title');
      });
      foreach ($books as $key => $val) {
        tr(function () {
          td($val['author']);
          td($val['title']);
        });
      }
    });
  } else {
    p('There are no books to display.');
  }
};

# or using a clean render() helper...
echo Puke\Base::render($view, ['books' => $data]);

# now try this
p('funny');

Note that a simple echo will not work as normally, use the text() helper inside the template to achieve the same result.

Eval is evil but seriously here he is the king.

Finally

There is not much to say, if you want contribute you're welcome buddy.