StringTemplateInterpreter

public class StringTemplateInterpreter : TemplateInterpreter<String>

This interpreter is used to evaluate string expressions and return a transformed string, replacing the content where it matches certain patterns. Typically used in web applications, where the rendering of an HTML page is provided as a template, and the application replaces certain statements, based on input parameters.

  • The result of a template evaluation is a String

    Declaration

    Swift

    public typealias EvaluatedType = String
  • The main part of the evaluation happens here. In this case, the global context variables merged with the provided context are going to be used.

    Declaration

    Swift

    public override func evaluate(_ expression: String, context: Context) -> String

    Parameters

    expression

    The input

    context

    Local context that is going to be used with this expression only

    Return Value

    The output of the evaluation