Literals (Preview)

Experimental Feature

Support for literal syntax within ESCL is currently experimental. This means that the functionality hasn't been thoroughly tested and may not behave as expected.

This functionality may change or be removed entirely in the future.

Do not use experimental features in production code.

Introduction

An experimental feature, literals allow you to hard-code values directly into clauses. By default, ESCL only supports referencing existing, pre-defined strings. However, sometimes it may be useful to just include a string directly.

String literals

A string literal is a string that is defined directly inside of a clause. As such, it does not have an identifier and cannot be referenced by other strings.

A string literal can be any string of characters, wrapped in single- or double-quotes.

In this example, the string literal "login" is passed to the LINK function:

hello_message: `Hello!  Please { LINK("login", :linkUrl) } to continue.`

Then, we translate the string, passing in the variable values:

$translate('hello_message', {
    linkUrl: 'profile.php'
});

The result:

Hello!  Please <a href="profile.php">login</a> to continue.

Last updated