Skip to main content

Templating

With the templating feature, you can insert environment values almost everywhere inside Kreya.

info

Starting with Kreya 1.7, directly referencing environment variables (ex. {{ endpoint }}) has been deprecated. Please use the env object to reference environment variables, for example {{ env.endpoint }}.

List of features that support templating:

  • Authentication
  • Default settings
  • Certificates
  • gRPC metadata
  • gRPC requests
  • gRPC endpoint
  • gRPC server reflection endpoint
  • REST headers
  • REST requests
  • REST endpoint
  • REST importers

Templating language

Kreya uses Scriban as its templating language. Usually, only variables are used, such as {{ env.endpoint }}. However, Scriban supports more complex features.

Take a look at the Scriban language guide and built in functions.

Generating fake data

In addition to the default Scriban features, Kreya also implements Bogus to allow fake data generation. For example, using

I am {{ faker.name.full_name }}

will result in a random name:

I am Jazlyn Gorczany

Referencing authentication configurations

Should you need to send authentication tokens via custom headers, in the request body or elsewhere, simply reference your existing authentication configurations. For example, if you have a basic authentication configuration called "My Auth":

The value of {{ auth.configs.my_auth.name }} is {{ auth.configs.my_auth.value }}

If you also need the "authentication prefix" (Basic, Bearer, ...), use prefixed_value instead of value.