Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Replace all data values from an array into a string using jQuery Template markup.
Public Shared Function RenderTemplate(template As String, list As Array) As String
Dim myRegexOptions As RegexOptions = RegexOptions.Multiline
Dim myRegex As New Regex(strRegex, myRegexOptions)
Dim splits = myRegex.Split(template)
Dim matches = myRegex.Matches(template)
Dim i As Integer = 0
Dim swap As Boolean = False
Dim str As New StringBuilder
For Each item In list
swap = False
For i = 0 To splits.Length - 1
If swap Then
str.Append(CallByName(item, splits(i), CallType.Get, Nothing))
End If
swap = Not swap
Return str.ToString
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment