Permalink
Browse files

Merge branch 'parameter-parse-change'

  • Loading branch information...
2 parents 3207d78 + 17d58f4 commit fc49e38985208dffcd28404032ebe410ddf9cc0b @hiddenmemory committed Apr 9, 2012
Showing with 277 additions and 131 deletions.
  1. +4 −4 Tests/Test01.html
  2. +12 −3 Tests/Test02.html
  3. +42 −0 Tests/Test04.html
  4. +3 −1 Tipi.xcodeproj/project.pbxproj
  5. +1 −0 Tipi/TPTemplateNode.h
  6. +4 −22 Tipi/TPTemplateNode.m
  7. +209 −99 Tipi/TPTemplateParser.m
  8. +2 −2 Tipi/main.m
View
@@ -1,13 +1,13 @@
-{{# def page title_test client_test }}
+{{# def page title client }}
<html>
<head>
- <title>{{ title_test }}</title>
+ <title>{{ title }}</title>
<meta name="author" value="{{ author }}">
</head>
- <body>{{ client_test }}</body>
+ <body>{{ client }}</body>
</html>
{{/ def }}
{{ def title "This is a title" }}
{{ def client "This is a client" }}
-{{ page title client }}
+{{ page title=title client=client }}
View
@@ -1,7 +1,9 @@
-{{#def case_study title_cs client_cs description_cs platform_cs testimonial_cs literal }}
+{{def author "Chris Ross"}}
+
+{{#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>
@@ -27,7 +29,14 @@ <h4>Technologies</h4>
{{/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
@@ -0,0 +1,42 @@
+{{def PollutionLevelFine="Pollution free zone"}}
+{{def PollutionLevel=PollutionLevelFine}}
+
+{{#def lorem}}
+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.
+{{/def}}
+
+{{#def test title="Default Title" content="Default Content"}}
+<title>{{title}}</title>
+<content>{{content}}</content>
+<pollution-level>{{PollutionLevel}}</pollution-level>
+{{/def}}
+
+-------------------
+No arguments:
+{{test}}
+-------------------
+
+-------------------
+Inline arguments:
+{{test content="Inline Content" title="Inline Title"}}
+-------------------
+
+-------------------
+Inline and bind arguments:
+{{#test title="Inline and bind"}}
+{{#bind content}}
+ {{lorem}}
+{{/bind}}
+{{#bind PollutionLevel}}
+ Polluting all the way.
+{{/bind}}
+{{/test}}
+-------------------
+
+-------------------
+Inline and bind arguments:
+{{#test title="Inline and bind"}}
+{{bind content="Bound content"}}
+{{bind PollutionLevel="Polluting all the way."}}
+{{/test}}
+-------------------
@@ -56,6 +56,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 831A8D0F1532F39F00E36646 /* Test04.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = Test04.html; sourceTree = "<group>"; };
838CA669152DB08F0013C064 /* Tipi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Tipi; sourceTree = BUILT_PRODUCTS_DIR; };
838CA66D152DB08F0013C064 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
838CA670152DB08F0013C064 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -66,7 +67,7 @@
838CA67F152DB11E0013C064 /* TPTextDataParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TPTextDataParser.h; sourceTree = "<group>"; };
838CA680152DB11E0013C064 /* TPTextDataParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TPTextDataParser.m; sourceTree = "<group>"; };
838CA683152DB39F0013C064 /* Test01.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Test01.txt; sourceTree = "<group>"; };
- 838CA687152DB55C0013C064 /* NSString+Tipi.h */ = {isa = PBXFileReference; fileEncoding = 4; path = "NSString+Tipi.h"; sourceTree = "<group>"; };
+ 838CA687152DB55C0013C064 /* NSString+Tipi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Tipi.h"; sourceTree = "<group>"; };
838CA688152DB55C0013C064 /* NSString+Tipi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Tipi.m"; sourceTree = "<group>"; };
838CA68A152DB59F0013C064 /* RegexKitLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegexKitLite.h; sourceTree = "<group>"; };
838CA68B152DB59F0013C064 /* RegexKitLite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegexKitLite.m; sourceTree = "<group>"; };
@@ -192,6 +193,7 @@
838CA723152DBE250013C064 /* Test01.html */,
83C656BC152DD61500454E32 /* Test02.html */,
83C656BE152DFFA200454E32 /* Test03.html */,
+ 831A8D0F1532F39F00E36646 /* Test04.html */,
);
path = Tests;
sourceTree = SOURCE_ROOT;
View
@@ -20,6 +20,7 @@ typedef enum {
@property (strong) NSString *originalValue;
@property (strong) NSString *name;
@property (readonly) NSMutableArray *values;
+@property (readonly) NSMutableDictionary *valuesMap;
@property (readonly) NSMutableArray *childNodes;
+ (TPTemplateNode*)node;
View
@@ -10,7 +10,7 @@
#import "NSString+Tipi.h"
@implementation TPTemplateNode
-@synthesize type, originalValue, name, values, childNodes;
+@synthesize type, originalValue, name, values, valuesMap, childNodes;
+ (TPTemplateNode*)node{
return [[TPTemplateNode alloc] init];
@@ -22,6 +22,7 @@ - (id)init {
self.originalValue = @"";
self.name = @"";
values = [NSMutableArray array];
+ valuesMap = [NSMutableDictionary dictionary];
childNodes = [NSMutableArray array];
}
return self;
@@ -66,27 +67,8 @@ - (NSString*)expansionUsingEnvironment:(NSMutableDictionary*)environment {
[expansion appendString:value];
}
else {
- NSString *(^expansionBlock)( TPTemplateNode *node, NSMutableDictionary *global, NSArray *parameters ) = value;
-
- NSMutableArray *parameters = [NSMutableArray array];
-
- for( NSString *_valueName in self.values ) {
- NSString *valueName = [_valueName lowercaseString];
- id valueValue = [environment objectForKey:valueName];
-
- if( valueValue == nil ) {
- [parameters addObject:_valueName];
- }
- else if( [[valueValue class] isSubclassOfClass:[NSString class]] ) {
- [parameters addObject:valueValue];
- }
- else {
- NSString *(^valueExpansionBlock)( TPTemplateNode *node, NSMutableDictionary *global, NSArray *parameters ) = valueValue;
- [parameters addObject:valueExpansionBlock(self, environment, nil)];
- }
- }
-
- [expansion appendString:expansionBlock(self, environment, parameters)];
+ NSString *(^expansionBlock)( TPTemplateNode *node, NSMutableDictionary *global ) = value;
+ [expansion appendString:expansionBlock(self, environment)];
}
}
else {
Oops, something went wrong.

0 comments on commit fc49e38

Please sign in to comment.