[Properties (by Name)] [Methods (by Name)] [Events (by Name)]
A class to parse templates.
Source position: fptemplate.pp line 56
type TTemplateParser = class(TObject) |
||
public |
||
constructor Create; |
|
Create a new instance of the template parser. |
destructor Destroy; override; |
|
Frees the template parser instance. |
procedure Clear; |
|
Clear the list of values. |
function ReplaceTag(); |
|
Replace a tag with a value. |
function GetParam(); |
|
Get a value for a parameter. |
procedure GetTagParams(); |
|
Extract tag parameters from a tag name. |
function ParseString(); |
|
Parse a string and substitute variables. |
function ParseStream(); |
|
Parse a stream and substitute variables. |
procedure ParseStrings(); |
|
Parse a stringlist and substitute variables. |
procedure ParseFiles(); |
|
Parse a file and substitute variables. |
property OnGetParam: TGetParamEvent; [rw] |
|
Event to get a value for a template variable. |
property OnReplaceTag: TReplaceTagEvent; [rw] |
|
Event to replace a tag. |
property StartDelimiter: TParseDelimiter; [rw] |
|
Start delimiter for a template variable. |
property EndDelimiter: TParseDelimiter; [rw] |
|
End delimiter for a template variable. |
property ParamStartDelimiter: TParseDelimiter; [rw] |
|
Start delimiter for a template variable parameter. |
property ParamEndDelimiter: TParseDelimiter; [rw] |
|
End delimiter for a template variable parameter. |
property ParamValueSeparator: TParseDelimiter; [rw] |
|
Separator for a template variable parameter and its value. |
property Values []: string; [rw] |
|
List of values for template variables. |
property ValuesByIndex []: string; [r] |
|
Access to values by index. |
property NamesByIndex []: string; [r] |
|
Access to variable names by index. |
property ValueCount: Integer; [r] |
|
Number of values in the list. |
property Recursive: Boolean; [rw] |
|
Enable recursive parsing. |
property AllowTagParams: Boolean; [rw] |
|
Allow tags with parameters. |
end; |
|
A class to parse templates. |
|
| | | ||
TTemplateParser is a class that can parse a text and substitute template variables with their values.
The template variables are enclosed in delimiters, by default { and }. Whenever a variable is found, its value is looked up in the Values property. If it is not found there, the OnGetParam event is called to obtain a value for the variable.
The delimiters can be set using the various delimiter properties.
If the text is deeply nested, an ETemplateParser exception may be raised.
|
Base class for templates. |