Simple variable replacement in a template.

ID: 1368

				
					using uCalcSoftware;

var uc = new uCalc();
var t = uc.NewTransformer();
// Define the data
uc.DefineVariable("user_name = 'Alice'");

// Define the placeholder rule
// '{' is a special character and must be escaped
t.FromTo("'{' '{' {expr} '}' '}'", "{@@Eval: expr}");

// Process the template
Console.WriteLine(t.Transform("Hello, {{ user_name }}!"));
				
			
Hello, Alice!
				
					#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   auto t = uc.NewTransformer();
   // Define the data
   uc.DefineVariable("user_name = 'Alice'");

   // Define the placeholder rule
   // '{' is a special character and must be escaped
   t.FromTo("'{' '{' {expr} '}' '}'", "{@@Eval: expr}");

   // Process the template
   cout << t.Transform("Hello, {{ user_name }}!") << endl;
}
				
			
Hello, Alice!
				
					Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim t = uc.NewTransformer()
      '// Define the data
      uc.DefineVariable("user_name = 'Alice'")
      
      '// Define the placeholder rule
      '// '{' is a special character and must be escaped
      t.FromTo("'{' '{' {expr} '}' '}'", "{@@Eval: expr}")
      
      '// Process the template
      Console.WriteLine(t.Transform("Hello, {{ user_name }}!"))
   End Sub
End Module
				
			
Hello, Alice!