romeoz / rock-template
Flexible template engine for PHP with MODx-like syntax
0.14.1
2015-10-23 15:59 UTC
Requires
- php: >=5.4.0
- romeoz/rock-components: 0.11.*
- romeoz/rock-execute: 0.10.*
- romeoz/rock-url: 0.11.*
Requires (Dev)
- phpunit/phpunit: ^4.7.0
- romeoz/rock-access: 0.10.*
- romeoz/rock-cache: 0.14.*
- romeoz/rock-date: 0.11.*
- romeoz/rock-filters: 0.10.*
- romeoz/rock-image: 0.10.*
- romeoz/rock-session: 0.11.*
Suggests
- romeoz/rock-cache: required for caching layouts, chunks, placeholders and others variables
- romeoz/rock-csrf: required for generating CSRF-token (security)
- romeoz/rock-date: required for building a datetime (DateTimeSnippet and filter date)
- romeoz/rock-filters: required for using filters for snippets
- romeoz/rock-image: required for editing a image (cropping, watermarks and etc)
- romeoz/rock-sanitize: required for sanitization rules a model
- romeoz/rock-validate: required for validation rules a model
- romeoz/rock-widgets: required for using a widgets
README
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
- Install Docker or askubuntu
docker run --name demo -d -p 8080:80 romeoz/docker-rock-template
- Open demo http://localhost:8080/
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.