ePages 6.10 - DE_EPAGES/TLE/API/TLE.pm

Package DE_EPAGES::TLE::API::TLE

This package provides a basic content based template processing.

Example
use DE_EPAGES::TLE::API::TLE qw( GetByteCodeByText ReplaceTLEVars );
my $Template = <<END_TEMPLATE;
  Scalar: #Scalar
  HashKey: #Hash.Key
  Loop: #LOOP(#List) #Value #ENDLOOP
END_TEMPLATE
my %TLE = (
    'Scalar' => 'Hello',
    'Hash' => { 'Key' => 'Value' },
    'List' => [ { 'Value' => 'V1' }, { 'Value' => 'V2' } ],
);
my $aByteCode = GetByteCodeByText( \$Template );
print ReplaceTLEVars( $aByteCode, \%TLE );
@EXPORT_OK
GetByteCodeByText
ReplaceTLEVars

Functions

GetByteCodeByText
ReplaceTLEVars

GetByteCodeByText

Compiles template text to Perl code. Throws an error if the template syntax is not correct.

Syntax
$PerlCode = GetByteCodeByText( $rPlainText );
Example
$PerlCode = GetByteCodeByText( \"#IF(#ExampleTLE)example TLE has value#ENDIF" );
Input
$rPlainText (ref.string)
text, may contain TLE language
Output
$PerlCode (string)
the compiled template as Perl source code

ReplaceTLEVars

This procedure uses a compiled TLE language to replace all occurencies according to the TLE syntax. For processing the base tle processor is used DE_EPAGES::TLE::API::BaseProcessor

Syntax
$replacedContent = ReplaceTLEVars($aByteCode, $hVars, $hContext);
Input
$aByteCode (ref.code)
compiled text
$hVars (hash reference)
TLE variables available to the replacer
$hContext (ref.hash)
options and special context information
e.g. MaxStackSize (maximum include depth)
Language. Howether the caller may pass in
additional values to ensure that these values are available
to the handlers
Return
$replacedContent (string)
the processed template