Sign in Join
FPDoc Onlineexperiment

TTemplateParser class

In unit fpTemplate

A class to parse templates.

Declaration

pascal
TTemplateParser = class(TObject)

Inheritance

  1. TTemplateParser
  2. TObject

Description

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.

Errors

If the text is deeply nested, an ETemplateParser exception may be raised.

See also

Properties

StartDelimiterpublicStart delimiter for a template variable.
EndDelimiterpublicEnd delimiter for a template variable.
ParamStartDelimiterpublicStart delimiter for a template variable parameter.
ParamEndDelimiterpublicEnd delimiter for a template variable parameter.
ParamValueSeparatorpublicSeparator for a template variable parameter and its value.
ValuespublicList of values for template variables.
ValuesByIndexpublicAccess to values by index.
NamesByIndexpublicAccess to variable names by index.
ValueCountpublicNumber of values in the list.
RecursivepublicEnable recursive parsing.
AllowTagParamspublicAllow tags with parameters.

Methods

CreatepublicCreate a new instance of the template parser.
DestroypublicFrees the template parser instance.
ClearpublicClear the list of values.
ReplaceTagpublicReplace a tag with a value.
GetParampublicGet a value for a parameter.
GetTagParamspublicExtract tag parameters from a tag name.
ParseStringpublicParse a string and substitute variables.
ParseStreampublicParse a stream and substitute variables.
ParseStringspublicParse a stringlist and substitute variables.
ParseFilespublicParse a file and substitute variables.

Events

OnGetParampublicEvent to get a value for a template variable.
OnReplaceTagpublicEvent to replace a tag.

Inherited

From TObject (40)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.