romeoz/rock-template

Flexible template engine for PHP with MODx-like syntax

0.14.1 2015-10-23 15:59 UTC

README

Latest Stable Version Total Downloads Build Status HHVM Status Coverage Status License

Features

  • Supports native PHP engine and declarative MODx-like syntax (placeholders, chunk, snippet,...)
  • Supports multi-engines
  • Multi-scopes ($root and $parent)
  • The variety of filters (arithmetic/bitwise operations, conditions, string, date, and url)
  • Custom auto-escaping
  • Support adding/customization filters and snippets
  • There is a possibility of adding custom extensions
  • Widgets
  • Caching all entities template engine
  • Standalone module/component for Rock Framework

Installation

From the Command Line:

composer require romeoz/rock-template

In your composer.json:

{
    "require": {
        "romeoz/rock-template": "*"
    }
}

Quick Start

###PHP engine

use rock\template\Template;

$template = new Template;

echo $template->render('/path/to/layout.php', ['foo' => 'world!!!']);

Contents layout.php:

<?php
/** @var \rock\template\Template $this */
?>

Hello <b><?=$this->foo?></b>

###Rock engine

use rock\template\Template;

echo (new Template)->render('/path/to/layout', ['foo' => 'world!!!']);

Contents layout.html:

Hello <b>[[+foo]]</b>

Documentation

Demo

Requirements

  • PHP 5.4+
  • For caching layouts, chunks, placeholders and others variables required Rock Cache: composer require romeoz/rock-cache
  • For using a widgets required Rock Widgets: composer require romeoz/rock-widgets
  • For validation rules a model required Rock Validate: composer require romeoz/rock-validate
  • For sanitization rules a model required Rock Sanitize: composer require romeoz/rock-sanitize
  • For using filters to snippets required Rock Filters: composer require romeoz/rock-filters
  • For editing a image (cropping, watermarks and etc) required Rock Image: composer require romeoz/rock-image
  • For generating CSRF-token (security) required Rock CSRF: composer require romeoz/rock-csrf
  • For building a datetime (DateTimeSnippet and filter date) required Rock DateTime: composer require romeoz/rock-date

All unbolded dependencies is optional

License

The Rock Template engine is open-sourced software licensed under the MIT license.