Documentation

Template
in package

Class defining template rendering.

Loads a template file, replaces all Placeholders and returns the replaced file content.

Tags
subpackage

includes

since
1.5.0
todo

Refactor templating.

Table of Contents

DASHBOARD  = 'admin/partials'
Directory name for dashboard partials.
PUBLIC  = 'public/partials'
Directory name for public partials.
$plugin_directory  : string
Plugin Directory
$original_content  : string|null
Contains the content of the template after initialize.
$replaced_content  : string
Contains the content of the template after initialize with replaced place holders.
__construct()  : void
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()  : string|bool
Get the template.
process_template()  : void
Process template file.
reload()  : void
Reloads the original content of the template file.
replace()  : bool
Replace all placeholders specified in array.

Constants

DASHBOARD

Directory name for dashboard partials.

public string DASHBOARD = 'admin/partials'
Tags
since
1.5.0

PUBLIC

Directory name for public partials.

public string PUBLIC = 'public/partials'
Tags
since
1.5.0

Properties

$plugin_directory

Plugin Directory

public string $plugin_directory
Tags
since
2.4.0d3

$original_content

Contains the content of the template after initialize.

private string|null $original_content = ''
Tags
since
1.5.0

$replaced_content

Contains the content of the template after initialize with replaced place holders.

private string $replaced_content = ''
Tags
since
1.5.0

Methods

__construct()

Class Constructor. Reads and loads the template file without replace any placeholder.

public __construct(string $file_type, string $file_name[, string $extension = 'html' ]) : void
Parameters
$file_type : string

Template file type.

$file_name : string

Template file name inside the partials/ directory, without the file extension.

$extension : string = 'html'

(optional) Template file extension (default: 'html').

Tags
since
1.5.0
todo

Refactor templating.

Return values
void

get_content()

Returns the content of the template file with replaced placeholders.

public get_content() : string
Tags
since
1.5.0
todo

Refactor templating.

Return values
string

Template content with replaced placeholders.

get_template()

Get the template.

public get_template(string $file_type, string $file_name[, string $extension = 'html' ]) : string|bool
Parameters
$file_type : string

The file type of the template.

$file_name : string

The file name of the template.

$extension : string = 'html'

The file extension of the template.

Tags
since
2.5.0
todo

Refactor templating.

todo

Single return type.

Return values
string|bool

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
since
2.4.0d3
todo

Refactor templating.

Return values
void

reload()

Reloads the original content of the template file.

public reload() : void
Tags
since
1.5.0
todo

Refactor templating.

Return values
void

replace()

Replace all placeholders specified in array.

public replace(array<string|int, string> $placeholders) : bool
Parameters
$placeholders : array<string|int, string>

Placeholders (key = placeholder, value = value).

Tags
since
1.5.0
todo

Refactor templating.

Return values
bool

true on Success, false if placeholders invalid.

Search results