Template
in package
FinalYes
Twig template engine wrapper class.
Provides Twig-based template rendering with CodeIgniter integration, cache busting for assets, and global variables (baseUrl, session, action).
Table of Contents
Properties
- $engine : Twig_Environment
- Twig_Environment instance.
Methods
- __construct() : mixed
- Initialize Template engine.
- load() : string
- Render a Twig template and return the compiled output.
Properties
$engine
Twig_Environment instance.
private
Twig_Environment
$engine
= null
Methods
__construct()
Initialize Template engine.
public
__construct([array{paths?: string[], environment?: array{cache?: string|false, debug?: bool, autoescape?: string|false}, lexer?: array{tag_comment?: array, tag_block?: array, tag_variable?: array, interpolation?: array}} $options = [] ]) : mixed
Automatically registers the cache_busting() function and global
variables (baseUrl, session, action) in the Twig environment.
Parameters
- $options : array{paths?: string[], environment?: array{cache?: string|false, debug?: bool, autoescape?: string|false}, lexer?: array{tag_comment?: array, tag_block?: array, tag_variable?: array, interpolation?: array}} = []
-
Configuration options:
-
paths: Template directory paths. Default is [VIEWPATH]. -
environment.cache: Compiled template cache path. Default from configcache_templates. -
environment.debug: Enable debug mode. Default is true for non-production. -
environment.autoescape: Auto-escaping strategy. Default is "html". -
lexer.tag_comment: Comment delimiters. Default is ['{#', '#}']. -
lexer.tag_block: Block delimiters. Default is ['{%', '%}']. -
lexer.tag_variable: Variable delimiters. Default is ['{{', '}}']. -
lexer.interpolation: Interpolation delimiters. Default is ['#{', '}'].
-
load()
Render a Twig template and return the compiled output.
public
load(string $templatePath[, array<string|int, mixed> $params = [] ][, string $ext = 'html' ]) : string
Parameters
- $templatePath : string
-
Template path relative to the template directory (without extension).
- $params : array<string|int, mixed> = []
-
Template variables for interpolation.
- $ext : string = 'html'
-
Template file extension. Default is "html".
Return values
string —Rendered template content.