Template
Class defining template rendering.
Loads a template file, replaces all Placeholders and returns the replaced file content.
Tags
Table of Contents
- C_STR_DASHBOARD = 'admin/partials'
- Directory name for dashboard partials.
- C_STR_PUBLIC = 'public/partials'
- Directory name for public partials.
- $plugin_directory : string
- Plugin Directory
- $a_str_original_content : string
- Contains the content of the template after initialize.
- $a_str_replaced_content : string
- Contains the content of the template after initialize with replaced place holders.
- __construct() : mixed
- Class Constructor. Reads and loads the template file without replace any placeholder.
- get_content() : string
- Returns the content of the template file with replaced placeholders.
- get_template() : mixed
- Get the template.
- process_template() : void
- Process template file.
- reload() : mixed
- Reloads the original content of the template file.
- replace() : bool
- Replace all placeholders specified in array.
Constants
C_STR_DASHBOARD
Directory name for dashboard partials.
public
string
C_STR_DASHBOARD
= 'admin/partials'
Tags
C_STR_PUBLIC
Directory name for public partials.
public
string
C_STR_PUBLIC
= 'public/partials'
Tags
Properties
$plugin_directory
Plugin Directory
public
string
$plugin_directory
Tags
$a_str_original_content
Contains the content of the template after initialize.
private
string
$a_str_original_content
= ''
Tags
$a_str_replaced_content
Contains the content of the template after initialize with replaced place holders.
private
string
$a_str_replaced_content
= ''
Tags
Methods
__construct()
Class Constructor. Reads and loads the template file without replace any placeholder.
public
__construct(string $p_str_file_type, string $p_str_file_name[, string $p_str_extension = 'html' ]) : mixed
Parameters
- $p_str_file_type : string
-
Template file type.
- $p_str_file_name : string
-
Template file name inside the
partials/
directory, without the file extension. - $p_str_extension : string = 'html'
-
(optional) Template file extension (default: 'html').
Tags
Return values
mixed —get_content()
Returns the content of the template file with replaced placeholders.
public
get_content() : string
Tags
Return values
string —Template content with replaced placeholders.
get_template()
Get the template.
public
get_template(string $p_str_file_type, string $p_str_file_name[, string $p_str_extension = 'html' ]) : mixed
Parameters
- $p_str_file_type : string
-
The file type of the template.
- $p_str_file_name : string
-
The file name of the template.
- $p_str_extension : string = 'html'
-
The file extension of the template.
Tags
Return values
mixed —false
or the template path
process_template()
Process template file.
public
process_template(string $template) : void
Parameters
- $template : string
-
The template to be processed.
Tags
Return values
void —reload()
Reloads the original content of the template file.
public
reload() : mixed
Tags
Return values
mixed —replace()
Replace all placeholders specified in array.
public
replace(array<string|int, mixed> $p_arr_placeholders) : bool
Parameters
- $p_arr_placeholders : array<string|int, mixed>
-
Placeholders (key = placeholder, value = value).
Tags
Return values
bool —true
on Success, false
if placeholders invalid.