Skip to main content

AML String Interpolation

Introduction

String interpolation is a method of embedding variable values directly into strings.

AML supports string interpolation for:

  • Normal string
  • Multi-line string
  • Heredoc content

Examples

const name_1 = 'John'
const name_2 = 'Alice'

'This is ${name_1}' // 'This is John'
"This is ${name_2}" // 'This is Alice'

'''
This
is
${name_1}
'''
/*
This
is
John
*/

// String interpolation in heredoc
const model = 'ecommerce.users'
@sql select * from ${model} ;; // select * from ecommerce.users

// use string interpolation with function and if else expression
Func greet(name: 'John' | 'Alice') {
"Hello, ${if (name == 'John') { 'sir' } else { 'madam'} }!"
}


Let us know what you think about this document :)