TextTemplate
TextTemplateBlock
P
rint
C
lose
documented with
GabLibrary Documentor.
(5/17/2007 2:55:02 PM)
Class TextTemplate
^
Represents a textbased template which can be used as content for emails, etc. It takes a file and replaces given placeholders with specific values. Placeholders can be common name value pairs or even whole blocks which hold name value pairs and can be duplicated several times. It's possible to create, modify and delete the templates. Example for the usage as an email template (first line of the template is used as subject): set t = new TextTemplate t.add "name", "John Doe" email.subject = t.getFirstLine() email.body = t.getAllButFirstLine()
Version:
1.2
Author:
Michal Gabrukiewicz - gabru @ grafix.at on 24.10.2003
Last modified:
17.05.2007 14:02:32
Path:
/gab_Library/class_textTemplate/TextTemplate.asp
Demo:
/gab_Library/class_textTemplate/demo/
Properties
^
Name
Type
Description
cleanParse
bool
should all unused blocks, vars, etc. been removed after parsing? default = true
content
string
GET: If no content is provided, we load the conents of the given file SET: Provide your own content.
fileName
string
The virtual path including the filename of your template. e.g. /userfiles/t.html
placeHolderBegin
string
If you want to use your own placeholder characters. this is the beginning. e.g. <<<
placeHolderEnd
string
If you want to use your own placeholder characters. this is the ending. e.g. >>>
UTF8
bool
is the template saved as UTF8 and should it be stored as UTF8?
Methods
^
add ( varName varValue )
adds a variable/block which should be replaced within the template
All placeholders in the template using this name (e.g. <<< VARNAME >>>) will be replaced by the value of the given variable. if the value was already added then it will be updated by the new value
varName
(
string
)
: The name of your variable when providing a Block the varname is the name of the block you want to add.
varValue
(
string
TextTemplateBlock
)
: The value which will be used. if its a block then provide a TextTemplateBlock instance
addVariable ( varName varValue )
the same as add(). check add() for details
varName
:
varValue
:
delete ( )
Deletes the text template file
getAllButFirstLine ( )
Returns the parsed file without the first line
getFirstLine ( )
Returns the first line of the template file
Returns the content of the first line of the template file. The place holders will be parsed as well
returnString ( )
Returns a string where the template and the placeholders are merged
save ( )
Saves the text template to the template directory
Class TextTemplateBlock
^
represents a block which is used within the TextTemplate Blocks are defined with <<< BLOCK NAME >>> ... <<< BLOCKEND NAME >>>. var can be defined between the "begin" and the "end" of the block. Each block can hold items which will be templated with the block
Version:
0.1
Author:
Michal Gabrukiewicz on 2006-10-28 14:36
Last modified:
17.05.2007 14:12:42
Path:
/gab_Library/class_textTemplate/class_TextTemplateBlock.asp
Demo:
/gab_Library/class_textTemplate/demo/
Properties
^
Name
Type
Description
items
dictionary
items of the block. key = autoID, value = array with vars.
Methods
^
addItem ( vars )
Adds an item to the block
the number of items will result in the same number of copied blocks.
vars
(
array
)
: a paired array. so 1st value is the name of the 1st var and 2nd value is is the value of the 1st var, etc. therfore number of values must be even! Example: (var1, value1, var2, value2, ...)