@@ -98,7 +98,6 @@ internal static TemplatedContent GenerateTemplateFromFileContents(string fileCon
98
98
string _replaceCode = string . Format ( "REPLACE_IF_CONDITION_{0}" , Guid . NewGuid ( ) . ToString ( ) . ToUpper ( ) ) ;
99
99
string subBlock = templatedContent . Template . GetSubstringByIndexStartAndEnd ( regexIfConditionMatch . Index + regexIfConditionMatch . Length , regexIfConditionMatchEnd . Index - 1 ) ;
100
100
//#Replace Template Block with unique Code
101
- //templatedContent.Template = templatedContent.Template.ReplaceFirstOccurrence(subBlock, _replaceCode);
102
101
templatedContent . Template = templatedContent . Template . ReplaceByIndexStartAndEnd ( regexIfConditionMatch . Index , ( regexIfConditionMatchEnd . Index - 1 ) + regexIfConditionMatchEnd . Length , _replaceCode ) ;
103
102
//#Append Condition Code
104
103
templatedContent . ReplaceIfConditionCodes . Add ( new ReplaceIfConditionCode
@@ -116,8 +115,8 @@ internal static TemplatedContent GenerateTemplateFromFileContents(string fileCon
116
115
#endregion
117
116
118
117
#region Generate Obj Looop
119
- Match regexLoopMatch = Regex . Match ( templatedContent . Template , "{{(.+?) for-each-start:(. +?)}}" , RegexOptions . IgnoreCase ) ;
120
- Match regexLoopEnd = Regex . Match ( templatedContent . Template , "{{(.+?) for-each-end:(. +?)}}" , RegexOptions . IgnoreCase ) ;
118
+ Match regexLoopMatch = Regex . Match ( templatedContent . Template , "{{\\ s* for-each-start:([^()] +?)\\ s* }}" , RegexOptions . IgnoreCase ) ;
119
+ Match regexLoopEnd = Regex . Match ( templatedContent . Template , "{{\\ s* for-each-end:([^()] +?)\\ s* }}" , RegexOptions . IgnoreCase ) ;
121
120
while ( regexLoopMatch . Success && regexLoopEnd . Success )
122
121
{
123
122
int startAtIndex = templatedContent . Template . IndexOf ( regexLoopMatch . Value ) ; //Getting again index just incase it was replaced
@@ -128,7 +127,7 @@ internal static TemplatedContent GenerateTemplateFromFileContents(string fileCon
128
127
string replaceCode = string . Format ( "REPLACE_LOOP_{0}" , Guid . NewGuid ( ) . ToString ( ) . ToUpper ( ) ) ;
129
128
templatedContent . Template = Regex . Replace ( templatedContent . Template , subBlock , replaceCode , RegexOptions . IgnoreCase ) ;
130
129
//Loop Target Object Name
131
- string targetObjName = regexLoopMatch . Value . Replace ( "{" , string . Empty ) . Replace ( "} " , string . Empty ) . Trim ( ) . Split ( new string [ ] { ":" } , StringSplitOptions . RemoveEmptyEntries ) . LastOrDefault ( ) ;
130
+ string targetObjName = ( regexLoopMatch . Groups . Count >= 1 ) ? regexLoopMatch . Groups [ 1 ] . Value ? . Trim ( ) ? . ToString ( ) ? . ToLower ( ) ? . Replace ( " " , string . Empty ) : string . Empty ;
132
131
//Obj
133
132
ReplaceObjLoopCode replaceObjLoopCode = new ReplaceObjLoopCode { ReplaceRef = replaceCode , TargetObjectName = targetObjName } ;
134
133
//Extra Loop Contents
0 commit comments