Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only ignore an empty token iff the parser is looking for a key name o…

…r equals, otherwise it coud be an empty string and we want those
  • Loading branch information...
commit fda649bed318464705220404ced3667bf5df4d30 1 parent 93a0984
@hiddenmemory authored
Showing with 30 additions and 21 deletions.
  1. +10 −3 Tests/Test02.html
  2. +19 −17 Tipi/TPTemplateParser.m
  3. +1 −1  Tipi/main.m
View
13 Tests/Test02.html
@@ -1,9 +1,9 @@
{{def author "Chris Ross"}}
-{{#def case_study title_cs client_cs description_cs platform_cs testimonial_cs literal }}
+{{#def case_study title client_cs description_cs platform_cs testimonial_cs literal }}
<html>
<head>
- <title>{{ title_cs }}</title>
+ <title>{{ title }}</title>
<meta name="author" value="{{ author }}">
</head>
<body>
@@ -29,7 +29,14 @@
{{/def}}
{{#include /Users/chris/Repositories/git/hiddenMemory/Tipi/Tests/Test01.txt}}
- {{#case_study title "" description platform Testimonial "v1.0"}}
+ {{#case_study
+ title=title
+ client_cs=""
+ description_cs=description
+ platform_cs=platform
+ testimonial_cs=Testimonial
+ literal="v1.0"
+ }}
{{# bind testvalue }}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
{{/ bind }}
View
36 Tipi/TPTemplateParser.m
@@ -223,13 +223,15 @@ - (BOOL)parseTag:(NSMutableString*)content parent:(TPTemplateNode*)parent {
while( [stringToParse length] ) {
NSString *token = [self nextToken:stringToParse];
- if( [token length] ) {
- switch( currentState ) {
- case STATE_WAITING_FOR_NAME:
+ switch( currentState ) {
+ case STATE_WAITING_FOR_NAME:
+ if( [token length] ) {
attributeName = token;
currentState = STATE_WAITING_FOR_EQUALS;
- break;
- case STATE_WAITING_FOR_EQUALS:
+ }
+ break;
+ case STATE_WAITING_FOR_EQUALS:
+ if( [token length] ) {
if( [token isEqualToString:@"="] ) {
currentState = STATE_WAITING_FOR_VALUE;
}
@@ -240,16 +242,16 @@ - (BOOL)parseTag:(NSMutableString*)content parent:(TPTemplateNode*)parent {
attributeValue = @"";
currentState = STATE_WAITING_FOR_EQUALS;
}
- break;
- case STATE_WAITING_FOR_VALUE:
- attributeValue = token;
- [parts addObject:attributeName];
- [baseEnvironment setObject:attributeValue forKey:attributeName];
- attributeValue = @"";
- attributeName = @"";
- currentState = STATE_WAITING_FOR_NAME;
- break;
- }
+ }
+ break;
+ case STATE_WAITING_FOR_VALUE:
+ attributeValue = token;
+ [parts addObject:attributeName];
+ [baseEnvironment setObject:attributeValue forKey:attributeName];
+ attributeValue = @"";
+ attributeName = @"";
+ currentState = STATE_WAITING_FOR_NAME;
+ break;
}
}
@@ -258,8 +260,8 @@ - (BOOL)parseTag:(NSMutableString*)content parent:(TPTemplateNode*)parent {
[baseEnvironment setObject:attributeValue forKey:attributeName];
}
-// NSLog(@"Parts: %@", parts);
-// NSLog(@"Base Environment: %@", baseEnvironment);
+ NSLog(@"Parts: %@", parts);
+ NSLog(@"Base Environment: %@", baseEnvironment);
[content deleteCharactersInRange:NSMakeRange(0, node.originalValue.length)];
View
2  Tipi/main.m
@@ -30,7 +30,7 @@ int main(int argc, const char * argv[]) {
TPDataParser *p = [TPMarkdownDataParser parserForFile:@"/Users/chris/Repositories/git/hiddenMemory/Tipi/Tests/Test01.txt"];
NSLog(@"p.values = %@", [p values]);
- TPTemplateParser *q = [TPTemplateParser parserForFile:@"/Users/chris/Repositories/git/hiddenMemory/Tipi/Tests/Test03.html"];
+ TPTemplateParser *q = [TPTemplateParser parserForFile:@"/Users/chris/Repositories/git/hiddenMemory/Tipi/Tests/Test02.html"];
NSLog(@"Expansion:\nSTART:\n%@:END", [q expansionUsingEnvironment:p.values]);
}
return 0;
Please sign in to comment.
Something went wrong with that request. Please try again.