Revision: 3029
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3029&view=rev
Author:   hofman
Date:     2007-10-10 10:49:30 -0700 (Wed, 10 Oct 2007)

Log Message:
-----------
Allow conditioning on comparison of properties in templates. When the value 
starts with $ it is interpreted as a key path instead of a constant value.

Modified Paths:
--------------
    trunk/SKTemplateParser.m

Modified: trunk/SKTemplateParser.m
===================================================================
--- trunk/SKTemplateParser.m    2007-10-07 18:08:40 UTC (rev 3028)
+++ trunk/SKTemplateParser.m    2007-10-10 17:49:30 UTC (rev 3029)
@@ -353,6 +353,8 @@
                             subTemplate = [subTemplate 
substringToIndex:wsRange.location];
                         
                         subTemplates = [[NSMutableArray alloc] init];
+                        if ([matchString hasPrefix:@"$"])
+                            matchString = [object 
safeValueForKeyPath:[matchString substringFromIndex:1]];
                         matchStrings = [[NSMutableArray alloc] 
initWithObjects:matchString ? matchString : @"", nil];
                         
                         if (matchType != SKConditionTagMatchOther) {
@@ -360,7 +362,9 @@
                             altTagRange = altTemplateTagRange(subTemplate, 
altTag, CONDITIONTAG_CLOSE_DELIM, &matchString);
                             while (altTagRange.location != NSNotFound) {
                                 [subTemplates addObject:[subTemplate 
substringToIndex:altTagRange.location]];
-                                [matchStrings addObject:matchString];
+                                if ([matchString hasPrefix:@"$"])
+                                    matchString = [object 
safeValueForKeyPath:[matchString substringFromIndex:1]];
+                                [matchStrings addObject:matchString ? 
matchString : @"", nil];
                                 subTemplate = [subTemplate 
substringFromIndex:NSMaxRange(altTagRange)];
                                 altTagRange = altTemplateTagRange(subTemplate, 
altTag, CONDITIONTAG_CLOSE_DELIM, &matchString);
                             }
@@ -581,6 +585,8 @@
                         subTemplate = [template 
attributedSubstringFromRange:NSMakeRange(start, [subTemplateString length] - 
wsRange.length)];
                         
                         subTemplates = [[NSMutableArray alloc] init];
+                        if ([matchString hasPrefix:@"$"])
+                            matchString = [object 
safeValueForKeyPath:[matchString substringFromIndex:1]];
                         matchStrings = [[NSMutableArray alloc] 
initWithObjects:matchString ? matchString : @"", nil];
                         
                         if (matchType != SKConditionTagMatchOther) {
@@ -588,7 +594,9 @@
                             altTagRange = altTemplateTagRange([subTemplate 
string], altTag, CONDITIONTAG_CLOSE_DELIM, &matchString);
                             while (altTagRange.location != NSNotFound) {
                                 [subTemplates addObject:[subTemplate 
attributedSubstringFromRange:NSMakeRange(0, altTagRange.location)]];
-                                [matchStrings addObject:matchString];
+                                if ([matchString hasPrefix:@"$"])
+                                    matchString = [object 
safeValueForKeyPath:[matchString substringFromIndex:1]];
+                                [matchStrings addObject:matchString ? 
matchString : @""];
                                 subTemplate = [subTemplate 
attributedSubstringFromRange:NSMakeRange(NSMaxRange(altTagRange), [subTemplate 
length] - NSMaxRange(altTagRange))];
                                 altTagRange = altTemplateTagRange([subTemplate 
string], altTag, CONDITIONTAG_CLOSE_DELIM, &matchString);
                             }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to