Template
Template
Smarty 2.0 Templates.
This class implements the entire Smarty 2.0 template specification. For documentation on the Smarty 2.0 template format see the Smarty 2.0 online documentation: https://www.smarty.net/docsv2/en/
Tags are in the format of {$tagname}. This tag would reference a parameter passed to the parser with the array key value of 'tagname'. Such as:
$tpl = new \Hazaar\Template\Smarty($template_content);
$tpl->render(['tagname' => 'Hello, World!']);
- Full name:
\Hazaar\Mail\Template
- Parent class:
\Hazaar\Template\Smarty
Inherited methods
__construct
Create a new Smarty template object.
public __construct(?string $content = null, string[] $include_funcs = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$content | ?string | |
$include_funcs | string[] |
loadFromString
Load the SMARTy template from a supplied string.
public loadFromString(string $content): void
Parameters:
Parameter | Type | Description |
---|---|---|
$content | string | The template source code |
loadFromFile
Read the template from a file.
public loadFromFile(\Hazaar\File $file): void
Parameters:
Parameter | Type | Description |
---|---|---|
$file | \Hazaar\File | can be either a Hazaar\File object or a string to a file on disk |
registerFunctionHandler
public registerFunctionHandler(object $object): void
Parameters:
Parameter | Type | Description |
---|---|---|
$object | object |
getTemplate
Returns the original un-compiled template.
public getTemplate(): string
prepend
Prepend a string to the existing content.
public prepend(string $string): void
Parameters:
Parameter | Type | Description |
---|---|---|
$string | string |
append
Append a string to the existing content.
public append(string $string): void
Parameters:
Parameter | Type | Description |
---|---|---|
$string | string |
render
Render the template with the supplied parameters and return the rendered content.
public render(array $params = []): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | array | parameters to use when embedding variables in the rendered template |
compile
Compile the template ready for rendering.
public compile(): string
This will normally happen automatically when calling Hazaar\Template\Smarty::render() but can be called separately if needed. The compiled template content is returned and can be stored externally.
setType
protected setType(mixed $value, string $type = 'string', ?string $args = null): string
Parameters:
Parameter | Type | Description |
---|---|---|
$value | mixed | |
$type | string | |
$args | ?string |
parsePARAMS
protected parsePARAMS(string $params, bool $keep_quotes = true): string[]
Parameters:
Parameter | Type | Description |
---|---|---|
$params | string | |
$keep_quotes | bool |
compileVAR
protected compileVAR(string $name): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
compileVARS
protected compileVARS(string $string): string
Parameters:
Parameter | Type | Description |
---|---|---|
$string | string |
replaceVAR
protected replaceVAR(string $name): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
replaceCONFIG_VAR
protected replaceCONFIG_VAR(string $name): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
compilePARAMS
protected compilePARAMS(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileIF
protected compileIF(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileELSEIF
protected compileELSEIF(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileELSE
protected compileELSE(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileENDIF
protected compileENDIF(): string
compileSECTION
protected compileSECTION(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileSECTIONELSE
protected compileSECTIONELSE(): string
compileENDSECTION
protected compileENDSECTION(): string
compileURL
protected compileURL(string $tag): string
Parameters:
Parameter | Type | Description |
---|---|---|
$tag | string |
compileFOREACH
protected compileFOREACH(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileFOREACHELSE
protected compileFOREACHELSE(): string
compileENDFOREACH
protected compileENDFOREACH(): string
compileLDELIM
protected compileLDELIM(): string
compileRDELIM
protected compileRDELIM(): string
compileCAPTURE
protected compileCAPTURE(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileENDCAPTURE
protected compileENDCAPTURE(): string
compileASSIGN
protected compileASSIGN(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileFUNCTION
protected compileFUNCTION(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileENDFUNCTION
protected compileENDFUNCTION(): string
compileCUSTOMFUNC
protected compileCUSTOMFUNC(string $name, mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | |
$params | mixed |
compileCUSTOMHANDLERFUNC
protected compileCUSTOMHANDLERFUNC(object $handler, string $method, mixed $params, int $index): string
Parameters:
Parameter | Type | Description |
---|---|---|
$handler | object | |
$method | string | |
$params | mixed | |
$index | int |
compileCALL
protected compileCALL(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
compileINCLUDE
protected compileINCLUDE(mixed $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | mixed |
Automatically generated on 2024-11-14