import ballerina/io;function main (string[] args) { string name = "Ballerina";
string template = string `Hello {{name}}!!!`;
io:println(template);
}
String TemplateString templates allow you to embed expressions in strings. You can add any expression inside {{}} as long as the expression produces a string type output after evaluating. |
|
import ballerina/io;
|
|
function main (string[] args) {
|
|
string name = "Ballerina";
|
|
string template = string `Hello {{name}}!!!`;
|
Create a string template. |
io:println(template);
}
|
Lets print the final string value of the template. |
$ ballerina run string-template.bal
Hello Ballerina!!!
|
To run the program, put the code in “string-template.bal” and use “ballerina run” command. |