Function parse

  • A template parser that processes text in a specific format:

    1. An optional vars section that looks like this:
    var1: value
    var2: value
    var2 (condition): value
    --

    Variable names may be repeated in the vars section.

    1. Then, a series of a mixture of plain text blocks and modifiers. Modifiers exist on a single line that begins and ends with [ and ]. They affect the following text block only. Text blocks are all other text.

    Modifiers can be joined on a single line by placing a semicolon between them, e.g. [modifier 1; modifier 2]

    This returns an object with two properties:

    • vars: a array of {name, condition, value} structures, where both condition and value are functions. The condition evaluates to whether the value should be set at all, and the value property evaluates to the value to set.
    • blocks: an array of {type, content} blocks

    Parameters

    • src: string
    • opts: {
          modifierPattern: RegExp;
          varsSep: RegExp;
      } = defaultOpts
      • modifierPattern: RegExp
      • varsSep: RegExp

    Returns ParseResult

Generated using TypeDoc