Tingle is a lightweight PHP template system that avoids the need for a
separate template language (like Smarty.) It will support add-on functionality
as “helpers” and the ability to use a layout template for consistent and DRY
code.
- PHP 5.3+ (Tingle uses namespaces)
- PHPUnit to run test suite
Unlike some other PHP template libraries that introduce a secondary template
“language,” Tingle uses plain PHP in its templates. It is up to the developer
to ensure separation between business logic and presentation.
Frameworks like the Zend Framework offer similar template systems, but make it
difficult to use only the template portion of the framework without including
loads of other classes. Tingle is focused on a single task – rendering
templates – and can be used by itself or incorporated into your PHP
application framework.
Tingle’s helper classes provide groups of methods that aid in producing your
application’s view layer. These are usually data formatting routines or macros
that reduce repetition in your templates. Each helper class defines one or
more methods that may be called from your template.
Layouts are templates that provide a common structure to your rendered views.
Typically you will use layouts to define the basic structure of your page. The
content of your view template will be inserted into the layout at the point(s)
you specify. This avoids the problem presented by other templating systems in
which you must split your layouts into a “header” template and a “footer”
template, and remember to include them in each of your views.
- Drop the Tingle library into your project.
- “require” lib/autoload.php in your PHP script.