Template Syntax Reference

Complete reference for all template functions, variables, and Faker generators

Template Variables

Capture data from incoming HTTP requests

get

Query Parameter

Extracts a value from URL query parameters

Syntax:

text
{{get 'parameterName'}}

Example:

json
// Request: GET /api/users?id=123&name=John

// Template:
{
  "userId": {{get 'id'}},
  "userName": {{get 'name'}}
}

// Response:
{
  "userId": 123,
  "userName": "John"
}

post

POST Form Data

Extracts a value from POST form data (application/x-www-form-urlencoded)

Syntax:

text
{{post 'fieldName'}}

Example:

json
// Request: POST /api/login
// Body: username=alice&password=secret

// Template:
{
  "loggedInUser": {{post 'username'}},
  "status": "success"
}

// Response:
{
  "loggedInUser": "alice",
  "status": "success"
}

json

JSON Body

Extracts a value from JSON request body (application/json)

Syntax:

text
{{json 'propertyName'}}

Example:

json
// Request: POST /api/users
// Body: {"name": "Bob", "age": 25}

// Template:
{
  "created": true,
  "user": {
    "name": {{json 'name'}},
    "age": {{json 'age'}}
  }
}

// Response:
{
  "created": true,
  "user": {
    "name": "Bob",
    "age": 25
  }
}

path

Path Segment

Extracts a path segment from the request URL by index (1-based)

Syntax:

text
{{path $index}}

Example:

json
// Request: GET /users/123/profile

// Template:
{
  "resource": {{path $1}},
  "userId": {{path $2}},
  "action": {{path $3}}
}

// Response:
{
  "resource": "users",
  "userId": "123",
  "action": "profile"
}

Note:

Path segments are indexed starting from 1 (not 0). The first segment after the domain is $1.

path.regex

Regex Capture Group

Extracts a captured group from a regular expression path pattern. Requires the Response path to use regex: prefix.

Syntax:

text
{{path.regex $index}}

Example:

json
// Response Path: regex:/users/(\d+)/posts/(\d+)
// Request: GET /users/456/posts/789

// Template:
{
  "userId": {{path.regex $1}},
  "postId": {{path.regex $2}},
  "title": {{faker 'lorem.sentence'}}
}

// Response:
{
  "userId": "456",
  "postId": "789",
  "title": "Lorem ipsum dolor sit amet."
}

πŸ’‘ Using Regex Paths

To use path.regex, set your Response path to a regex pattern starting with regex:/. Use parentheses () to create capture groups.

Example paths: regex:/users/(\d+), regex:/api/v(\d+)/products/([a-z]+)

Control Structures

Create loops and dynamic data structures

{{#repeat N}}

Loop

Repeats the enclosed content N times

Syntax:

text
{{#repeat count}}
  // Content to repeat
{{/repeat}}

Example:

json
{
  "users": [
    {{#repeat 3}}
    {
      "id": {{@index}},
      "name": {{faker 'person.name'}}
    }
    {{/repeat}}
  ]
}

// Generates 3 user objects with auto-incremented IDs

@index

Iterator

Current iteration index with optional start and step values

Syntax Variants:

text
{{@index}}         // 0, 1, 2, 3, 4...
{{@index 1}}       // 1, 2, 3, 4, 5...
{{@index 100}}     // 100, 101, 102, 103...
{{@index 0 2}}     // 0, 2, 4, 6, 8...
{{@index 1 10}}    // 1, 11, 21, 31, 41...

Parameters:

  • start (optional): Starting value (default: 0)
  • step (optional): Increment value (default: 1)

Special Functions

jwt

Authentication

Generates a JWT (JSON Web Token) with specified expiration time

Syntax:

text
{{jwt expirationSeconds}}

Example:

json
{
  "token": {{jwt 3600}},     // Expires in 1 hour
  "refreshToken": {{jwt 86400}} // Expires in 24 hours
}

Common Expiration Times:

  • 3600 = 1 hour
  • 86400 = 24 hours (1 day)
  • 604800 = 7 days
  • 2592000 = 30 days

Faker Functions (20+)

Generate realistic fake data for various domains

General Syntax

text
{{faker 'category.function'}}

All Faker functions follow this pattern. Some functions don't require a category (e.g., email).

Locale Support

Specify a locale using a colon (:) to generate data in different languages.

Syntax:

text
{{faker 'function:locale'}}
{{faker 'function(args):locale'}}

Examples:

text
{{faker 'person.name'}}              // Default: en_US
{{faker 'person.name:en_US'}}        // English
{{faker 'person.name:ko_KR'}}        // Korean
{{faker 'person.name:ja_JP'}}        // Japanese
{{faker 'address.city:fr_FR'}}       // French
{{faker 'sentence(5):en_US'}}        // English sentence (5 words)

Supported Locales:

Common Locales:

  • en_US - English (US) - Default
  • ko_KR - Korean
  • ja_JP - Japanese
  • fr_FR - French
  • de_DE - German
  • es_ES - Spanish
  • it_IT - Italian
  • pt_BR - Portuguese (Brazil)
  • zh_CN - Chinese (Simplified)
  • ru_RU - Russian

Locale-Dependent Functions:

  • person.* - Names, first names, last names
  • address.* - Cities, states, streets, etc.
  • company.* - Company names, job titles
  • phone.* - Phone numbers
  • word - Single words
  • sentence - Sentences
  • paragraph - Paragraphs
  • text - Text blocks

Note: All locale-dependent functions are fully supported in ko_KR locale, including company functions (company, companySuffix, bs, jobTitle) and text functions (word, sentence, paragraph, text) with native Korean content. Text functions support arguments with maximum limits (sentence: 100 words, paragraph: 20 sentences, text: 5,000 characters).

Person

Generate person-related data

{{faker 'person.name'}}
John Doe
{{faker 'person.name:ko_KR'}}
κΉ€μ² μˆ˜
{{faker 'person.firstName'}}
Jane
{{faker 'person.firstNameMale'}}
John
{{faker 'person.firstNameFemale'}}
Jane
{{faker 'person.lastName'}}
Smith

Internet

Generate internet and web-related data

{{faker 'email'}}
user@example.com
{{faker 'safeEmail'}}
user@example.org
{{faker 'userName'}}
john_doe123
{{faker 'password'}}
P@ssw0rd123!
{{faker 'domainName'}}
example.com
{{faker 'url'}}
https://example.com
{{faker 'ipv4'}}
192.168.1.1
{{faker 'ipv6'}}
2001:0db8:85a3::8a2e:0370:7334

Address

Generate address and location data

{{faker 'address.city'}}
New York
{{faker 'address.city:ko_KR'}}
μ„œμšΈ
{{faker 'address.state'}}
California
{{faker 'address.country'}}
United States
{{faker 'address.postcode'}}
90210
{{faker 'address.streetAddress'}}
123 Main St
{{faker 'address.streetName'}}
Main Street
{{faker 'address.latitude'}}
34.0522
{{faker 'address.longitude'}}
-118.2437

Company

Generate company and business data

{{faker 'company.company'}}
Acme Corporation
{{faker 'company.company:ko_KR'}}
ν…Œν¬μ†”λ£¨μ…˜
{{faker 'company.companySuffix'}}
Inc
{{faker 'company.companySuffix:ko_KR'}}
μ£Όμ‹νšŒμ‚¬
{{faker 'company.bs'}}
synergize markets
{{faker 'company.bs:ko_KR'}}
ν˜μ‹ μ μΈ μ†”λ£¨μ…˜μ„ μ œκ³΅ν•©λ‹ˆλ‹€
{{faker 'company.jobTitle'}}
Software Engineer
{{faker 'company.jobTitle:ko_KR'}}
μ†Œν”„νŠΈμ›¨μ–΄ μ—”μ§€λ‹ˆμ–΄

Text

Generate placeholder text

Korean Support: Text functions (word, sentence, paragraph, text) are now fully supported in ko_KR locale with native Korean content.

{{faker 'word'}}
ipsum
{{faker 'word:ko_KR'}}
사과
{{faker 'sentence'}}
Lorem ipsum dolor sit amet.
{{faker 'sentence:ko_KR'}}
μ˜€λŠ˜μ€ 정말 쒋은 λ‚ μ”¨μž…λ‹ˆλ‹€.
{{faker 'sentence(10):ko_KR'}}
10개 λ‹¨μ–΄λ‘œ κ΅¬μ„±λœ λ¬Έμž₯ (μ΅œλŒ€ 100단어)
{{faker 'paragraph'}}
Lorem ipsum dolor...
{{faker 'paragraph:ko_KR'}}
λ””μ§€ν„Έ μ‹œλŒ€κ°€ λ„λž˜ν•˜λ©΄μ„œ...
{{faker 'paragraph(5):ko_KR'}}
5개 λ¬Έμž₯으둜 κ΅¬μ„±λœ 문단 (μ΅œλŒ€ 20λ¬Έμž₯)
{{faker 'text'}}
Long text content...
{{faker 'text:ko_KR'}}
ν•œκ΅­μ–΄ κΈ΄ ν…μŠ€νŠΈ...
{{faker 'text(500):ko_KR'}}
500자 ν…μŠ€νŠΈ (μ΅œλŒ€ 5,000자)

Function Arguments & Limits:

  • sentence(n) - Generate sentence with n words (max: 100 words)
  • paragraph(n) - Generate paragraph with n sentences (max: 20 sentences)
  • text(n) - Generate text with n characters (max: 5,000 characters)

Number & String

Generate random numbers and values

{{faker 'randomNumber'}}
12345
{{faker 'randomDigit'}}
7
{{faker 'randomFloat'}}
123.45
{{faker 'boolean'}}
true
{{faker 'randomLetter'}}
a

Date & Time

Generate date and time values

{{faker 'unixTime'}}
1609459200
{{faker 'dateTime'}}
2024-01-15 14:30:00
{{faker 'iso8601'}}
2024-01-15T14:30:00Z
{{faker 'date'}}
2024-01-15
{{faker 'time'}}
14:30:00

Payment

Generate payment and card data

{{faker 'creditCardType'}}
Visa
{{faker 'creditCardNumber'}}
4111111111111111
{{faker 'iban'}}
GB29 NWBK 6016 1331 9268 19
{{faker 'swiftBicNumber'}}
NWBKGB2L

Phone

Generate phone numbers

{{faker 'phone.phoneNumber'}}
(555) 123-4567
{{faker 'phone.phoneNumber:ko_KR'}}
010-1234-5678
{{faker 'phone.e164PhoneNumber'}}
+15551234567

Color

Generate color values

{{faker 'hexColor'}}
#3B82F6
{{faker 'rgbColor'}}
59,130,246
{{faker 'colorName'}}
blue

Image

Generate image URLs

{{faker 'imageUrl'}}
https://picsum.photos/640/480
{{faker 'imageUrl(500,500)'}}
https://picsum.photos/500/500
{{faker 'gravatarUrl'}}
https://www.gravatar.com/avatar/...

UUID & Barcode

Generate unique identifiers and barcodes

{{faker 'uuid'}}
550e8400-e29b-41d4-a716-446655440000
{{faker 'ean13'}}
1234567890123
{{faker 'isbn13'}}
978-1234567890

User Agent

Generate browser user agent strings

{{faker 'userAgent'}}
Mozilla/5.0...
{{faker 'chrome'}}
Chrome user agent
{{faker 'firefox'}}
Firefox user agent

Miscellaneous

Hashes, emojis, and more

{{faker 'md5'}}
5d41402abc4b2a76b9719d911017c592
{{faker 'sha256'}}
2c26b46b68...
{{faker 'emoji'}}
πŸ˜€

Validation Rules

Template syntax is validated in real-time in the editor

Common Validation Errors

❌ Unclosed template tag

json
{
  "name": {{faker 'person.name'
}

Missing closing }

❌ Unclosed repeat block

json
{{#repeat 10}}
  {"id": {{@index}}}
// Missing {{/repeat}}

❌ Invalid argument type

text
{{get id}}      // Missing quotes for string argument
{{jwt "3600"}}   // Should be number, not string

βœ… Correct syntax

json
{
  "name": {{faker 'person.name'}},
  "id": {{get 'userId'}},
  "token": {{jwt 3600}}
}

Validation Features

  • Real-time syntax checking as you type
  • Inline error markers with line and column numbers
  • Auto-completion for template functions
  • Validation of template function names and arguments
  • JSON structure validation (after template processing)
  • Bracket and parenthesis matching
Template Syntax Reference - DoMock Documentation