diff --git a/MGTemplateStandardMarkers.m b/MGTemplateStandardMarkers.m index df4fcf3..13c480d 100644 --- a/MGTemplateStandardMarkers.m +++ b/MGTemplateStandardMarkers.m @@ -389,6 +389,19 @@ - (NSObject *)markerEncountered:(NSString *)marker withArguments:(NSArray *)args argTrue = (num1 <= num2); } else if ([op isEqualToString:@"\%"]) { argTrue = ((num1 % num2) > 0); + } else if ([op isEqualToString:@"equalsstring"]) { + NSObject *firstVal = [engine resolveVariable:firstArg]; + NSObject *secondVal = [engine resolveVariable:secondArg]; + if (!firstVal) { + firstVal = firstArg; + } + if (!secondVal) { + secondVal = secondArg; + } + if (firstVal && secondVal) { + //NSLog(@"%@ %@", [NSString stringWithFormat:@"%@", firstVal], [NSString stringWithFormat:@"%@", secondVal]); + argTrue = [[NSString stringWithFormat:@"%@", firstVal] isEqualToString:[NSString stringWithFormat:@"%@", secondVal]]; + } } } diff --git a/sample_template.txt b/sample_template.txt index f0fb1bf..06d4343 100644 --- a/sample_template.txt +++ b/sample_template.txt @@ -5,7 +5,7 @@ It's currently {% now | date_format: "dd MMM yyyy 'at' HH:mm:ss" %} Nested variable: {{ foo.bar }} {% for dude in guys %} - Current dude is {{ dude | uppercase }}... + Current dude is {{ dude | uppercase }}...{% if dude equalsString "matt" %} AWESOME!{% /if %} {% if currentLoop.currentIndex == 0 %} (the best!) {% comment %} Should only happen for Matt {% /comment %} {% for 1 to 5 %}*{% /for %}