Skip to content

Commit

Permalink
search for templates in a relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Pauly committed Jul 29, 2014
1 parent e609c03 commit f598e62
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/classes/GRMustacheTemplateRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,14 @@ - (void)dealloc

- (id<NSCopying>)templateRepository:(GRMustacheTemplateRepository *)templateRepository templateIDForName:(NSString *)name relativeToTemplateID:(id)baseTemplateID
{
return [_bundle pathForResource:name ofType:_templateExtension];
if (baseTemplateID) {
NSString *relativePath = [baseTemplateID stringByDeletingLastPathComponent];
relativePath = [relativePath stringByReplacingOccurrencesOfString:_bundle.resourcePath withString:@""];

return [_bundle pathForResource:name ofType:_templateExtension inDirectory:relativePath];
} else {
return [_bundle pathForResource:name ofType:_templateExtension];
}
}

- (NSString *)templateRepository:(GRMustacheTemplateRepository *)templateRepository templateStringForTemplateID:(id)templateID error:(NSError **)error
Expand Down

2 comments on commit f598e62

@marcpalmer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit broke localisation of templates. Partials in folders like 'en.lproj' discovered by NSBundle cause this relative lookup mechanism to break.

@groue
Copy link
Owner

@groue groue commented on f598e62 Dec 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is exact. This commit belongs to pull request #78, which was a valid use case. The fix for your #87 will have to keep support for #78.

Please sign in to comment.