Smarty
Smarty
The View\Template class.
- Full name:
\Hazaar\File\Template\Smarty
- Parent class:
\Hazaar\Template\Smarty
Properties
cache_enabled
public static bool $cache_enabled
- This property is static.
__cache_enabled
private bool $__cache_enabled
__source_file
private ?\Hazaar\File $__source_file
__cache_file
private ?\Hazaar\File $__cache_file
__cwd
private string $__cwd
Methods
__construct
Create a new Smarty template object.
public __construct(string $file, ?bool $cache_enabled = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$file | string | |
$cache_enabled | ?bool |
__destruct
public __destruct(): mixed
loadFromFile
Read the template from a file.
public loadFromFile(\Hazaar\File|string $file): void
Parameters:
Parameter | Type | Description |
---|---|---|
$file | \Hazaar\File|string | can be either a Hazaar\File object or a string to a file on disk |
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.
render
Render the template with the supplied parameters and return the rendered content.
public render(array $params = []): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | array |
compileCONFIG_LOAD
Compile the CONFIG_LOAD tag.
public compileCONFIG_LOAD(string $params): string
Parameters:
Parameter | Type | Description |
---|---|---|
$params | string |
getCompiledContentFromCache
private getCompiledContentFromCache(): false|string
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