/simple-php-templates

Extremely lightweight PHP template engine

Primary LanguagePHP

Dirt-Simple PHP Templates

This is an extremely lightweight template engine that allows your application’s HTML to be fully decoupled from your PHP. This template engine runs at near-native speeds thanks to its built-in compiler, making it much faster than similar interpreted template engines. Almost no performance overhead is present on a properly cached setup.

For full documentation, please see the Github Wiki page: https://github.com/Darth-Apple/simple-php-templates/wiki

Features

  • Single file template engine. Fits in under 10KB (uncompressed)
  • Flexible template variables
  • Automatic auto-escaping (variables can also be inserted unescaped)
  • If/elseif/else expressions (with rich evaluation)
  • Event Listeners (specialized template hooks)
  • Template loops
  • Load nested templates with [@template:mytemplate] tags.
  • Blocks (standard template extensions/inheritance)
  • Clean, simple syntax.

This engine is ideal for small, simple projects that need a capable, secure, and fast template engine. It is also in use for various homegrown CMS projects and is developed to be capable of serving full applications. Installation is quick and easy, and the overhead is minimal.

Installation & Usage

This engine is packaged entirely within a single file. Installation is quick and easy. See the wiki page for detailed instructions.

https://github.com/Darth-Apple/simple-php-templates/wiki

How it Works

This bedrock of this template engine is its built-in compiler. All templates are converted to raw PHP and are cached/executed on-the-fly. This enables the template syntax to extend various features that already exist within the PHP language without adding a large footprint or overhead. This page describes the technical underpinnings in detail: https://github.com/Darth-Apple/simple-php-templates/wiki/How-It-Works

About:

  • Version: Beta 2
  • License: LGPL version 3 (message me if you need a different license)
  • Size: 1 file, < 10Kb