Feature Request: Email String Interpolation - Evaluate Variables withing HTML Tag

I wanted to check if there inbuilt activity that does the simplifies email templating easily.

For instance, it is very cumbersome to replace the variables withing the HTML markup text for email:

"<h1>"+strTitle+"</h1>"

Instead of this, the templating would assume something like:

"<h1>__${strTitle}</h1>"

Would automatically attempt to replace the variable value within the text.

I am unaware if such feature already exists.

2 Likes

If you are using body type as HTML you can pass variables which can be replaced by desired text

Yes, but that is very tedious and error prone, because you have to split the HTML code and then append the variable value in the markup.

"....some very long html markup here......"+someVar+"another very long html markup here"+..

Once you get use to it, it is not that much tedious :grinning:

I found this is not called String Templating but String interpretation.
I found this link
c# - What's a good way of doing string templating in .NET? - Stack Overflow.
I will try to have something like this.

use this code:

Dim RenderExpr As Regex = New Regex(“\.|{([a-z0-9_.-]+)}”, RegexOptions.IgnoreCase Or RegexOptions.Compiled)

StringOutput = RenderExpr.Replace(StringTemplate, Function ( Match )
If (Replacers.ContainsKey(Match.Groups(1).Value)) Then
Return Replacers(Match.Groups(1).Value).ToString()
End If
End Function
)

use it as an invoke code activity;
StringTemplate, StringOutput as variables
Replacers as IDictionary with the substitutions i.e: Replacers = new Dictionary(Of String,Object) From { {“fecha”, “2020-01-02”}, {“hora”, “10:30”} }

then invoke a string template with its substitutions: “siendo las {hora} del {fecha}, vamos a ejecutar este string”

and see the result in StringOutput variable.

it could be used to do similar activity than string interpolation but with strings instead of numbers (Take in mind that strong interpolation is made at compile time).

hope that it helps as a workaround.