Generates content based on a template and a Data Source, by looping through every Input-row in the Data Source and applying the template to each row, e.g. to create a list of items with various information about each item.
Syntax
string FillTemplate( string template, string sourceName,
string separator = "\r\n", string filter = "", string sort = "" )Method Parameters
|
string template |
The template to use for each row in the Data Source. |
|
string sourceName |
Name of the Data Source containing the rows to iterate through and apply content from to the template. The Data Source must be of the Table type. |
|
string separator |
The content that is used to separate each iteration of the template. Default: \r\n (carriage return + line feed) If you want to generate html content, you might want to substitute this with a <br> |
|
string filter |
Optional expression used to filter rows, similar to SQL. Example: "Cylinder=8 AND Price > AVG(Price)" For more specific documentation on the filter-syntax, check the Microsoft documentation for the DataView RowFilter Syntax [C#]. |
|
string sort |
Optional value specifying the column to sort and direction. Example: "Price ASC" |
Example
Below example shows how to define a template in html-format, and include lookups of values from the input-row, such as {id} and {Value} and {ShortText}.
string template = "<a href='http://www.perfion.com?pid={id}'>{Value}</a><br><i>{ShortText}</i><br>";
string message = FillTemplate( template, "Items", "<br>" );It is also possible to reference values from variables by writing e.g. {=$WebRoot} to lookup the value of a globally defined variable $WebRoot.
To make editing the template easier, it can be stored in a variable and defined using e.g. the SET command, and instead reference the variable in the above example code.
Comments
0 comments
Please sign in to leave a comment.