Void readFromTemplate(ElementTree location, String input, WhiteList safety, Doctype doctype, Dict<String, ElementTree([Pair<String, String> ])> templates, Bool lazy=true)
Arguments
location: The location in the document to append the converted Stringinput: The String to convertsafety: The allowed elements and attributesdoctype: The document type of the input string. This is independent of the document type of the document and controls certain aspects of parsing - for example, if the doctype isHTML4Strict, the end tags forportdelements may be omitted, and the code will be case-insensitive. As usual, parsing with XHTML strictness will be quicker. TheTagSoupoption is equivalent toHTML4Strict- templates should be good quality!templates: A dictionary of templating functions. The key is the name of the templating tag, and the value is the function to call upon seeing that tag (which will be passed the templating tags attributes as a list of pairs).lazy: Evaluate templates lazily. Enabling this will reduce memory usage, especially in complex nested templates, but may cause problems if the templates have side effects or use global variables. Set this option tofalseto evaluate templates immediately. This argument is optional and defaults totrue.
Usage
Convert a HTML template String to HTML. An Exception will be thrown if the parser cannot construct an unambiguous tree from the string, and it is considerably less forgiving than the parsers in most web browsers. (On the other hand, it's a bit more forgiving in places than a strict XML parser, especially if the HTML4Strict doctype is used).
A HTML template String contains empty tags with user-defined names. These tags are then replaced with the output of the function defined for that tag in the templates dictionary.
Read the WhiteList documentation for important information on safety when converting these Strings, and bear in mind that allowing user-supplied data to call templating functions is only as secure as the allowed templating functions.