Download the PHP package wpscholar/templatex without Composer
On this page you can find all versions of the php package wpscholar/templatex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wpscholar/templatex
More information about wpscholar/templatex
Files in wpscholar/templatex
Package templatex
Short Description A simple, micro template engine for PHP
License Unlicense
Informations about the package templatex
TemplateX
A simple, micro template engine for PHP
Getting Started
Loading your template:
The template file:
Documentation
Is
Check if a variable has a specific value.
Params:
- string - Name of the variable to check.
- mixed - Value to check.
Return Value:
boolean
Description:
The
is()
method allows you to check if a variable in the template's context contains a specific value.
Has
Check if a variable exists.
Params:
- string|array - Name of the variable to check, or a path to a nested value.
Return Value:
boolean
Description:
The
has()
method allows you to check if a variable exists in the template's context. You can pass in a variable name, or a path to a nested data structure. For example, you can pass in an array, or use dot notation (e.g.var.0.title
will look for a variable namedvar
, find the first item in the array, and then find the title property from the object).
Has In
Check if a value exists in an object or an array.
Params:
- object|array - Data from which to locate value.
- string|array - Name of variable, or nested path.
Return Value:
boolean
Description:
The
hasIn()
method is the same as thehas()
method, except you can pass in your own data as opposed to defaulting to the template's context.
Get
Get a variable.
Params:
- string|array - Name (or path) of the variable to be fetched.
- string|array - The default value to be returned if variable doesn't exist.
Return Value:
mixed
Description:
The
get()
method allows you to fetch a value from the template's context. You can pass in a variable name, or a path to a nested data structure. For example, you can pass in an array, or use dot notation (e.g.var.0.title
to get the title property from the first value in the array contained in the variable namedvar
.) Optionally, you can pass in a default value to be returned if the variable you are asking for isn't defined.
Get In
Get a value from an object or an array.
Params:
- object|array - Data from which to fetch value.
- string|array - Name (or path) of the variable to be fetched.
- mixed - The default value to be returned if variable doesn't exist.
Return Value:
mixed
Description:
The
getIn()
method is the same as theget()
method, except you can pass in your own data as opposed to defaulting to the template's context.
Set
Set a variable.
Params:
- string|array - Name (or path) of the variable to be set.
- mixed - The value to be assigned.
Return Value:
void
Description:
The
set()
method allows you to set a value in the template's context. You can pass in a variable name, or a path to a nested data structure. For example, you can pass in an array, or use dot notation (e.g.var.0.title
to set the title property from the first value in the array contained in the variable namedvar
.) Optionally, you can pass in a default value to be returned if the variable you are asking for isn't defined.
Set In
Set a value in an object or an array.
Params:
- object|array - Data in which to set value.
- string|array - Name (or path) of the variable to be set.
- mixed - The value to be assigned.
Return Value:
mixed - Returns the updated data or original data on failure.
Description:
The
setIn()
method is the same as theset()
method, except you can pass in your own data as opposed to defaulting to the template's context.
Delete
Unset a variable.
Params:
- string|array - Name of the variable to be deleted.
Return Value:
void
Description:
The
delete()
method will remove a variable from the template's context.
Load
Loads a template from within an existing template.
Params:
- string - Relative path to the template to be loaded.
- array - An associative array containing variable names and values to pass to the template.
- boolean - Whether or not to keep the variables from the parent template's context.
Return Value:
void
Description:
The
load()
method will output a child template within a template.
Render
Render a template to a string.
Params:
none
Return Value:
string
Description:
The
render()
method will return a string containing the rendered template.
Set Template
Set the template to be rendered.
Params:
string - Relative path to the template to be rendered.
Return Value:
void
Description:
The
setTemplate()
method is how you set the template that you want to render. It will be the relative path to the template (e.g.event.php
).
Set Context
Set the context.
Params:
array - An associative array containing variable names and values to pass to the template.
Return Value:
void
Description:
The
setContext()
method allows you to pass variables to the template's context. Any variables passed will be made available to the template being rendered.
Set Template Paths
Set the template paths.
Params:
array - An array of template paths.
Return Value:
void
Description:
The
setTemplatePaths()
method allows you to define one or more template paths to check when attempting to load a template.
Add Template Path
Add a template path.
Params:
string - A template path to append to the list of template paths.
Return Value:
void
Description:
The
addTemplatePath()
method allows you to append a template path to the list of template paths to check when attempting to load a template.