Fork me on GitHub

H2o is template engine for PHP, there are a lot of the concept are inspired by projects like Django templates, Smarty and Jinja, implemented in a way that makes sense in PHP. Author your template the easy way ... It's authored by Taylor Luk, Founder of Issue

  1. Readable and natural syntax.
  2. Reuse template inclusion and inheritance.
  3. Extensible through filters, tags and template extensions.
  4. Battery included - bundled rich set of filters and tags
  5. Internationalization
  6. Various caching support with multiple back-end

Dependencies

PHP 5.1 +

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

 $ git clone git://github.com/speedmax/h2o-php

Resources

Install

Download and extract h2o in your project path or your php include path

Sample file structure setup

myawesome_app/
  index.php
  templates/
    index.html
  h2o/
  1. use require 'h2o/h2o.php' in your php statement to include h2o library
  2. Below is a quick start code example to get a kick start
  3. checkout example and specs if you are in the mood for exploration.

templates/index.html

<html>
  <head><title>{{ page.title }}</title></head>
  <body>
    {{ page.body }}
  </body>
</html>

index.php

<?php
require 'h2o/h2o.php';

$h2o = new h2o('index.html');

$page = array(
  'title' => 'title of a page',
  'body' => 'Hello world'
);

# render your awesome page
echo $h2o->render(compact('page'));
?>

License

The MIT License Copyright (c) 2008 Taylor Luk

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the “Software”), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors

Taylor Luk (aka speedmax) (subjective@gmail.com), Blog here, currently working on Shop2, A personalised shopping catalog.