Template Delimiters Configuration

Overview

The default delimiters for placeholders and scriptlets in a Simula Template are as follow:

  • ${ and } denote the beginning and end of a placeholder.

  • <% and %> enclose scriptlets.

These delimiters can be changed for a simlet as explained in the next section.

Changing the Delimiters

Here is how to change the default delimiters for placeholders and scriptlets in a Simula template - by using the "delimiters" field:

#...

response:
  from: template
  template: Simula
  delimiters:
    # Do not use '<<' or '>>' as delimiters because they are
    # also left and right shift operators, respectively.
    # Also, do not use '{' as left delimiters because that is
    # the beginning of a block in the Groovy scripting language.
    #
    # It can be very confusing to use mustache-style delimiters
    # in JSON body payload...but, yes, it is possible.
    #
    # Configuring Python Jinja-like {% %} delimiters for scriptlets.
    placeholder:
      left: "{{"
      right: "}}"
    scriptlet:
      left: "{%"
      right: "%}"

  status: 200
  headers:
  - "Content-Type: application/json; charset=UTF-8"

  body: |+
    {
      "queryStringParms": {
        "total": {{ QueryStringParms.count() }},
        "postalCode": "{{ QueryStringParms['postalCode'][0] }}",
        "isDebug": {% if ( {{ QueryStringParms.contain('debug') }} != null ) { %}true{% } else { %}false{% } %}
      }
    }

Change either one of the default delimiters for placeholders and scriptlets, or both. Change only the left or only the right delimiter, or both…​


We would love to hear your feedback! Shoot us a quick email to [feedback at APISimulator.com] to let us know what you think.

Happy API Simulating!