Created
May 26, 2011 21:53
-
-
Save digiguru/994172 to your computer and use it in GitHub Desktop.
Replace all data values from an array into a string using jQuery Template markup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
Else | |
str.Append(splits(i)) | |
End If | |
swap = Not swap | |
Next | |
Next | |
Return str.ToString | |
End Function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment