Functions used to configure and transfer templates.
sendTemplate() | Configures template file and possibly sends it to the remote end. |
Configures template file and possibly sends it to the remote end.
sendTemplate( stream, [tpd], [inMemory] )
stream | A Falcon stream opened for reading (or a memory string stream). | ||
tpd | Data for template conversion. | ||
inMemory | Work in memory and return the result instead sending it. | ||
Returns: | The configured contents of the file if inMemory is true. | ||
Raises: |
|
This function reads a text as-is (in binary mode) and flushes its contents to the remote side stream.
If a dictionary is set as template conversion data, the data in the file is converted so that strings between a pair of '%' symbols are expanded in the text coresponding to the key in the dictionary. In example, if this is a template file:
My name is %name%, pleased to meet you!
The %name% configurable text may be changed into "John Smith" throught the following call:
sendTemplate( InputStream("mytemplate.txt"), ["name" => "John Smith"] )
If a configurable text is not found in the tpd dictionary, it is removed. The specal sequence '%%' may be used to write a single '%'.
Note: Maximum lenght of template configurable strings is 64.