String Interpolation
or variable binding
C++20
via std::format
Crystal
Work alike ruby with either #{}
a = 1
b = 2
"sum: #{a} + #{b} = #{a + b}" # => "sum: 1 + 2 = 3"
or %{} (native similar to Mustache).
"sum: %{one} + %{two} = %{three}" % {one: 1, two: 2, three: 1 + 2} # => "sum: 1 + 2 = 3"
D
Ruby
name = "James"
puts "Hello, #{name}" // Hello, James
- On data read from a file - (native similar to Mustache).
vars = { name: "James"}
mystring = "Hello, %{name}" // content of file, using %{} tags
mystring % vars // => Hello, James, == string.format
Scala
val name = "James"
println(s"Hello, $name") // Hello, James
Javascript/Typescript
let value = 100;
console.log(`The size is ${ value }`);
m4
maven
- parameter expansion -> see maven filtering
templates
Written on August 27, 2018, Last update on August 30, 2023
crystal
ruby
scala
dlang
string
interpolation