TemplateProcessor
public class TemplateProcessor
Utility to replace double brace wrapped text with values extracted from a DataObject.
-
Processes the input
textlooking for all occurrences of double brace wrapped text:{{ }}The format of text inside the braces can be as follows:
- a valid json path style string: e.g.
{{container.key}} - a valid json path style string with an optional fallback: e.g.
{{container.key || fallback}}- in the event that
container.keyis not available in thecontextobject, the fallback will be used
- in the event that
All occurrences of the templating
{{ }}will be replaced with either the value from thecontextobject according to the json path specified, or the fallback string if provided, else a blank string""Declaration
Swift
public class func process(text: String, context: DataObject) -> StringParameters
textthe String to process for
{{ }}substitution blockcontextthe
DataObjectto extract values fromReturn Value
A new string with all substitution blocks replaced
- a valid json path style string: e.g.
View on GitHub