Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

code cleanup

  • Loading branch information...
commit e0d442aa75f74b25abed93521fc8f80da373258b 1 parent 1998b1b
@groue authored
View
14 src/classes/GRMustacheCompiler.m
@@ -302,13 +302,9 @@ - (BOOL)parser:(GRMustacheParser *)parser shouldContinueAfterParsingToken:(GRMus
return NO;
}
- // Validate the renderingElementForTemplateName:error: contract:
- // Non nil, non empty, white-space stripped template name.
- NSAssert([_currentOpeningToken.partialName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length > 0, @"WTF parser?");
-
- // Ask templateRepository for super template
+ // Ask templateRepository for overridable template
NSError *templateError;
- id<GRMustacheRenderingElement> template = [_templateRepository renderingElementForTemplateName:_currentOpeningToken.partialName error:&templateError];
+ GRMustacheTemplate *template = [_templateRepository templateForName:_currentOpeningToken.partialName error:&templateError];
if (template == nil) {
[self failWithFatalError:templateError];
return NO;
@@ -338,13 +334,9 @@ - (BOOL)parser:(GRMustacheParser *)parser shouldContinueAfterParsingToken:(GRMus
return NO;
}
- // Validate the renderingElementForTemplateName:error: contract:
- // Non nil, non empty, white-space stripped template name.
- NSAssert([token.partialName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length > 0, @"WTF parser?");
-
// Ask templateRepository for partial template
NSError *templateError;
- id<GRMustacheRenderingElement> template = [_templateRepository renderingElementForTemplateName:token.partialName error:&templateError];
+ GRMustacheTemplate *template = [_templateRepository templateForName:token.partialName error:&templateError];
if (template == nil) {
[self failWithFatalError:templateError];
return NO;
View
18 src/classes/GRMustacheTemplateRepository.m
@@ -204,7 +204,7 @@ - (void)dealloc
- (GRMustacheTemplate *)templateForName:(NSString *)name error:(NSError **)outError
{
- return [self templateForName:name relativeToTemplateID:nil error:outError];
+ return [self templateForName:name relativeToTemplateID:_currentlyParsedTemplateID error:outError];
}
- (GRMustacheTemplate *)templateFromString:(NSString *)templateString error:(NSError **)outError
@@ -216,11 +216,6 @@ - (GRMustacheTemplate *)templateFromString:(NSString *)templateString error:(NSE
return [GRMustacheTemplate templateWithInnerElements:renderingElements];
}
-- (id<GRMustacheRenderingElement>)renderingElementForTemplateName:(NSString *)name error:(NSError **)outError
-{
- return [self templateForName:name relativeToTemplateID:_currentlyParsedTemplateID error:outError];
-}
-
#pragma mark Private
- (NSArray *)renderingElementsFromString:(NSString *)templateString templateID:(id)templateID error:(NSError **)outError
@@ -254,7 +249,10 @@ - (NSArray *)renderingElementsFromString:(NSString *)templateString templateID:(
- (GRMustacheTemplate *)templateForName:(NSString *)name relativeToTemplateID:(id)baseTemplateID error:(NSError **)outError
{
- id templateID = [self.dataSource templateRepository:self templateIDForName:name relativeToTemplateID:baseTemplateID];
+ id templateID = nil;
+ if (name) {
+ templateID = [self.dataSource templateRepository:self templateIDForName:name relativeToTemplateID:baseTemplateID];
+ }
if (templateID == nil) {
if (outError != NULL) {
*outError = [NSError errorWithDomain:GRMustacheErrorDomain
@@ -296,9 +294,9 @@ - (GRMustacheTemplate *)templateForName:(NSString *)name relativeToTemplateID:(i
// We are about to compile templateString. GRMustacheCompiler may
- // invoke [self renderingElementForTemplateName:error:] when compiling
- // partial tags {{> name }}. Since partials are relative, we need to
- // know the ID of the currently parsed template.
+ // invoke [self templateForName:error:] when compiling partial tags
+ // {{> name }}. Since partials are relative, we need to know the ID of
+ // the currently parsed template.
//
// And since partials may embed other partials, we need to handle the
// currently parsed template ID in a recursive way.
View
17 src/classes/GRMustacheTemplateRepository_private.h
@@ -91,21 +91,4 @@
// Documented in GRMustacheTemplateRepository.h
- (GRMustacheTemplate *)templateFromString:(NSString *)templateString error:(NSError **)outError GRMUSTACHE_API_PUBLIC;
-/**
- * This method returns a rendering element that represents a template.
- *
- * The _name_ parameter is guaranteed to be not nil, non empty, and stripped of
- * white-space characters.
- *
- * @param name The template name
- * @param outError If there is an error loading or parsing the tempalte,
- * upon return contains an NSError object that describes
- * the problem.
- *
- * @return A <GRMustacheRenderingElement> instance
- *
- * @see GRMustacheCompiler
- * @see GRMustacheRenderingElement
- */
-- (id<GRMustacheRenderingElement>)renderingElementForTemplateName:(NSString *)name error:(NSError **)outError GRMUSTACHE_API_INTERNAL;
@end
Please sign in to comment.
Something went wrong with that request. Please try again.