diff --git a/Classes/GRMustacheBundleTemplateLoader.m b/Classes/GRMustacheBundleTemplateLoader.m index 0c28c2aa..513d2fb7 100644 --- a/Classes/GRMustacheBundleTemplateLoader.m +++ b/Classes/GRMustacheBundleTemplateLoader.m @@ -39,6 +39,13 @@ - (id)templateIdForTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseT return [bundle URLForResource:name withExtension:self.extension]; } +- (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError { + NSAssert([templateId isKindOfClass:[NSURL class]], nil); + return [NSString stringWithContentsOfURL:(NSURL*)templateId + encoding:self.encoding + error:outError]; +} + - (void)dealloc { [bundle release]; [super dealloc]; diff --git a/Classes/GRMustacheBundleTemplateLoader_private.h b/Classes/GRMustacheBundleTemplateLoader_private.h index 23b1b0c4..6fe19cef 100644 --- a/Classes/GRMustacheBundleTemplateLoader_private.h +++ b/Classes/GRMustacheBundleTemplateLoader_private.h @@ -20,10 +20,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "GRMustacheURLTemplateLoader_private.h" +#import "GRMustacheTemplateLoader_private.h" -@interface GRMustacheBundleTemplateLoader: GRMustacheURLTemplateLoader { +@interface GRMustacheBundleTemplateLoader: GRMustacheTemplateLoader { @private NSBundle *bundle; } diff --git a/Classes/GRMustacheDirectoryTemplateLoader.m b/Classes/GRMustacheDirectoryTemplateLoader.m index 2a3b04b3..d6ecf614 100644 --- a/Classes/GRMustacheDirectoryTemplateLoader.m +++ b/Classes/GRMustacheDirectoryTemplateLoader.m @@ -46,6 +46,13 @@ - (id)templateIdForTemplateNamed:(NSString *)name relativeToTemplateId:(id)baseT return [[[url URLByAppendingPathComponent:name] URLByAppendingPathExtension:self.extension] URLByStandardizingPath]; } +- (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError { + NSAssert([templateId isKindOfClass:[NSURL class]], nil); + return [NSString stringWithContentsOfURL:(NSURL*)templateId + encoding:self.encoding + error:outError]; +} + - (GRMustacheTemplate *)parseContentsOfURL:(NSURL *)templateURL error:(NSError **)outError { NSString *templateString = [NSString stringWithContentsOfURL:templateURL encoding:self.encoding error:outError]; if (!templateString) { diff --git a/Classes/GRMustacheDirectoryTemplateLoader_private.h b/Classes/GRMustacheDirectoryTemplateLoader_private.h index 91b356d3..ef849064 100644 --- a/Classes/GRMustacheDirectoryTemplateLoader_private.h +++ b/Classes/GRMustacheDirectoryTemplateLoader_private.h @@ -20,10 +20,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "GRMustacheURLTemplateLoader_private.h" +#import "GRMustacheTemplateLoader_private.h" -@interface GRMustacheDirectoryTemplateLoader: GRMustacheURLTemplateLoader { +@interface GRMustacheDirectoryTemplateLoader: GRMustacheTemplateLoader { @private NSURL *url; } diff --git a/Classes/GRMustacheURLTemplateLoader.m b/Classes/GRMustacheURLTemplateLoader.m deleted file mode 100644 index 3c52a1b8..00000000 --- a/Classes/GRMustacheURLTemplateLoader.m +++ /dev/null @@ -1,35 +0,0 @@ -// The MIT License -// -// Copyright (c) 2010 Gwendal Roué -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "GRMustacheURLTemplateLoader_private.h" - - -@implementation GRMustacheURLTemplateLoader - -- (NSString *)templateStringForTemplateId:(id)templateId error:(NSError **)outError { - NSAssert([templateId isKindOfClass:[NSURL class]], nil); - return [NSString stringWithContentsOfURL:(NSURL*)templateId - encoding:self.encoding - error:outError]; -} - -@end diff --git a/Classes/GRMustacheURLTemplateLoader_private.h b/Classes/GRMustacheURLTemplateLoader_private.h deleted file mode 100644 index 90b8b41c..00000000 --- a/Classes/GRMustacheURLTemplateLoader_private.h +++ /dev/null @@ -1,27 +0,0 @@ -// The MIT License -// -// Copyright (c) 2010 Gwendal Roué -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "GRMustacheTemplateLoader_private.h" - - -@interface GRMustacheURLTemplateLoader: GRMustacheTemplateLoader -@end diff --git a/GRMustache.xcodeproj/project.pbxproj b/GRMustache.xcodeproj/project.pbxproj index 0f133987..431055a4 100644 --- a/GRMustache.xcodeproj/project.pbxproj +++ b/GRMustache.xcodeproj/project.pbxproj @@ -67,7 +67,6 @@ 5648DB0A1297CF34001423FE /* GRMustacheVariableElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 5611542F127EC68000F01AD0 /* GRMustacheVariableElement.m */; }; 5648DB0B1297CF34001423FE /* GRMustacheDirectoryTemplateLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 56D87FEE1285A77100F5CF76 /* GRMustacheDirectoryTemplateLoader.m */; }; 5648DB0C1297CF34001423FE /* GRMustacheVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 56A2A197128D28F300B33845 /* GRMustacheVersion.m */; }; - 5648DB0D1297CF34001423FE /* GRMustacheURLTemplateLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 56A2A3511290450400B33845 /* GRMustacheURLTemplateLoader.m */; }; 5648DB591297D4D5001423FE /* libsyck.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56D87EC7128578D100F5CF76 /* libsyck.a */; }; 5648DB5A1297D4EB001423FE /* GSNSDataExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 56D87EC6128578D100F5CF76 /* GSNSDataExtensions.m */; }; 5648DB5B1297D4EB001423FE /* SyckInput.m in Sources */ = {isa = PBXBuildFile; fileRef = 56D87ECA128578D100F5CF76 /* SyckInput.m */; }; @@ -77,7 +76,6 @@ 566F45D9129AA59F00767AA3 /* GRMustacheToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 56339C8C129A4C01000B6F2C /* GRMustacheToken.m */; }; 566F45DA129AA5A300767AA3 /* GRMustacheTemplateParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 56339AD812992E4F000B6F2C /* GRMustacheTemplateParser.m */; }; 56A2A198128D28F300B33845 /* GRMustacheVersion.m in Sources */ = {isa = PBXBuildFile; fileRef = 56A2A197128D28F300B33845 /* GRMustacheVersion.m */; }; - 56A2A3521290450400B33845 /* GRMustacheURLTemplateLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 56A2A3511290450400B33845 /* GRMustacheURLTemplateLoader.m */; }; 56C99CA912872AFA00A25402 /* core in Resources */ = {isa = PBXBuildFile; fileRef = 56C99C9D12872AFA00A25402 /* core */; }; 56C99DD11288840800A25402 /* GRMustacheLambdaSectionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 56C99DD01288840800A25402 /* GRMustacheLambdaSectionTest.m */; }; 56C99DF812888B2A00A25402 /* dot_key in Resources */ = {isa = PBXBuildFile; fileRef = 56C99DF312888B2A00A25402 /* dot_key */; }; @@ -163,8 +161,6 @@ 5648DCCA129902E4001423FE /* GRMustacheTokenizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRMustacheTokenizer.m; sourceTree = ""; }; 56A2A196128D28F300B33845 /* GRMustacheVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GRMustacheVersion.h; sourceTree = ""; }; 56A2A197128D28F300B33845 /* GRMustacheVersion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRMustacheVersion.m; sourceTree = ""; }; - 56A2A3501290450400B33845 /* GRMustacheURLTemplateLoader_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GRMustacheURLTemplateLoader_private.h; sourceTree = ""; }; - 56A2A3511290450400B33845 /* GRMustacheURLTemplateLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRMustacheURLTemplateLoader.m; sourceTree = ""; }; 56C99C9D12872AFA00A25402 /* core */ = {isa = PBXFileReference; lastKnownFileType = folder; name = core; path = "Mustache-Spec/specs/core"; sourceTree = SOURCE_ROOT; }; 56C99DCF1288840800A25402 /* GRMustacheLambdaSectionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GRMustacheLambdaSectionTest.h; sourceTree = ""; }; 56C99DD01288840800A25402 /* GRMustacheLambdaSectionTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRMustacheLambdaSectionTest.m; sourceTree = ""; }; @@ -264,50 +260,80 @@ name = Frameworks; sourceTree = ""; }; - 56115416127EC67F00F01AD0 /* Classes */ = { + 560A7F2A129F88FB0051AE0A /* AbstractTree */ = { isa = PBXGroup; children = ( - 56115CF11281DD3300F01AD0 /* GRBoolean.h */, - 56115CF21281DD3300F01AD0 /* GRBoolean.m */, - 56115417127EC67F00F01AD0 /* GRMustache.h */, - 56115418127EC67F00F01AD0 /* GRMustache.m */, - 56115419127EC67F00F01AD0 /* GRMustache_private.h */, - 56D87FEB1285A77100F5CF76 /* GRMustacheBundleTemplateLoader.m */, - 56D87FEA1285A77100F5CF76 /* GRMustacheBundleTemplateLoader_private.h */, - 5611541B127EC68000F01AD0 /* GRMustacheContext.m */, - 5611541C127EC68000F01AD0 /* GRMustacheContext_private.h */, - 56D87FEE1285A77100F5CF76 /* GRMustacheDirectoryTemplateLoader.m */, - 56D87FED1285A77100F5CF76 /* GRMustacheDirectoryTemplateLoader_private.h */, - 56D1A5AB129BEE6900BA5799 /* GRMustacheRendering.m */, - 5611541D127EC68000F01AD0 /* GRMustacheRendering_private.h */, - 56115420127EC68000F01AD0 /* GRMustacheError.h */, - 56115421127EC68000F01AD0 /* GRMustacheError.m */, - 56115422127EC68000F01AD0 /* GRMustacheLambda.h */, - 56115423127EC68000F01AD0 /* GRMustacheLambda.m */, - 56115424127EC68000F01AD0 /* GRMustacheLambda_private.h */, 56115425127EC68000F01AD0 /* GRMustacheSectionElement.m */, 56115426127EC68000F01AD0 /* GRMustacheSectionElement_private.h */, 56115427127EC68000F01AD0 /* GRMustacheTemplate.h */, 56115428127EC68000F01AD0 /* GRMustacheTemplate.m */, 56115429127EC68000F01AD0 /* GRMustacheTemplate_private.h */, - 5611542A127EC68000F01AD0 /* GRMustacheTemplateLoader.h */, - 5611542B127EC68000F01AD0 /* GRMustacheTemplateLoader.m */, - 5611542C127EC68000F01AD0 /* GRMustacheTemplateLoader_private.h */, - 56D87FEC1285A77100F5CF76 /* GRMustacheTemplateLoader_protected.h */, 5611542D127EC68000F01AD0 /* GRMustacheTextElement.m */, 5611542E127EC68000F01AD0 /* GRMustacheTextElement_private.h */, - 56A2A3501290450400B33845 /* GRMustacheURLTemplateLoader_private.h */, - 56A2A3511290450400B33845 /* GRMustacheURLTemplateLoader.m */, 5611542F127EC68000F01AD0 /* GRMustacheVariableElement.m */, 56115430127EC68000F01AD0 /* GRMustacheVariableElement_private.h */, - 56A2A196128D28F300B33845 /* GRMustacheVersion.h */, - 56A2A197128D28F300B33845 /* GRMustacheVersion.m */, - 5648DCC9129902E4001423FE /* GRMustacheTokenizer_private.h */, - 5648DCCA129902E4001423FE /* GRMustacheTokenizer.m */, - 56339AD712992E4F000B6F2C /* GRMustacheTemplateParser_private.h */, + ); + name = AbstractTree; + sourceTree = ""; + }; + 560A7F2B129F891F0051AE0A /* Loading */ = { + isa = PBXGroup; + children = ( + 56D87FEB1285A77100F5CF76 /* GRMustacheBundleTemplateLoader.m */, + 56D87FEA1285A77100F5CF76 /* GRMustacheBundleTemplateLoader_private.h */, + 56D87FEE1285A77100F5CF76 /* GRMustacheDirectoryTemplateLoader.m */, + 56D87FED1285A77100F5CF76 /* GRMustacheDirectoryTemplateLoader_private.h */, + 5611542A127EC68000F01AD0 /* GRMustacheTemplateLoader.h */, + 5611542B127EC68000F01AD0 /* GRMustacheTemplateLoader.m */, + 5611542C127EC68000F01AD0 /* GRMustacheTemplateLoader_private.h */, + 56D87FEC1285A77100F5CF76 /* GRMustacheTemplateLoader_protected.h */, + ); + name = Loading; + sourceTree = ""; + }; + 560A7F2C129F89380051AE0A /* Parsing */ = { + isa = PBXGroup; + children = ( 56339AD812992E4F000B6F2C /* GRMustacheTemplateParser.m */, - 56339C8B129A4C01000B6F2C /* GRMustacheToken_private.h */, + 56339AD712992E4F000B6F2C /* GRMustacheTemplateParser_private.h */, 56339C8C129A4C01000B6F2C /* GRMustacheToken.m */, + 56339C8B129A4C01000B6F2C /* GRMustacheToken_private.h */, + 5648DCCA129902E4001423FE /* GRMustacheTokenizer.m */, + 5648DCC9129902E4001423FE /* GRMustacheTokenizer_private.h */, + ); + name = Parsing; + sourceTree = ""; + }; + 560A7F2D129F89560051AE0A /* Rendering */ = { + isa = PBXGroup; + children = ( + 56115CF11281DD3300F01AD0 /* GRBoolean.h */, + 56115CF21281DD3300F01AD0 /* GRBoolean.m */, + 5611541B127EC68000F01AD0 /* GRMustacheContext.m */, + 5611541C127EC68000F01AD0 /* GRMustacheContext_private.h */, + 56115422127EC68000F01AD0 /* GRMustacheLambda.h */, + 56115423127EC68000F01AD0 /* GRMustacheLambda.m */, + 56115424127EC68000F01AD0 /* GRMustacheLambda_private.h */, + 56D1A5AB129BEE6900BA5799 /* GRMustacheRendering.m */, + 5611541D127EC68000F01AD0 /* GRMustacheRendering_private.h */, + ); + name = Rendering; + sourceTree = ""; + }; + 56115416127EC67F00F01AD0 /* Classes */ = { + isa = PBXGroup; + children = ( + 560A7F2D129F89560051AE0A /* Rendering */, + 560A7F2C129F89380051AE0A /* Parsing */, + 560A7F2B129F891F0051AE0A /* Loading */, + 560A7F2A129F88FB0051AE0A /* AbstractTree */, + 56115417127EC67F00F01AD0 /* GRMustache.h */, + 56115418127EC67F00F01AD0 /* GRMustache.m */, + 56115419127EC67F00F01AD0 /* GRMustache_private.h */, + 56115420127EC68000F01AD0 /* GRMustacheError.h */, + 56115421127EC68000F01AD0 /* GRMustacheError.m */, + 56A2A196128D28F300B33845 /* GRMustacheVersion.h */, + 56A2A197128D28F300B33845 /* GRMustacheVersion.m */, ); path = Classes; sourceTree = ""; @@ -533,7 +559,6 @@ 5648DB021297CF0D001423FE /* GRMustacheBundleTemplateLoader.m in Sources */, 5648DB0B1297CF34001423FE /* GRMustacheDirectoryTemplateLoader.m in Sources */, 5648DB0C1297CF34001423FE /* GRMustacheVersion.m in Sources */, - 5648DB0D1297CF34001423FE /* GRMustacheURLTemplateLoader.m in Sources */, 5648DAF91297CD38001423FE /* main.m in Sources */, 5648DCCB129902E4001423FE /* GRMustacheTokenizer.m in Sources */, 566F45D9129AA59F00767AA3 /* GRMustacheToken.m in Sources */, @@ -572,7 +597,6 @@ 56D881691285C74800F5CF76 /* GRMustacheTemplateLoaderSubclassTest.m in Sources */, 56C99DD11288840800A25402 /* GRMustacheLambdaSectionTest.m in Sources */, 56A2A198128D28F300B33845 /* GRMustacheVersion.m in Sources */, - 56A2A3521290450400B33845 /* GRMustacheURLTemplateLoader.m in Sources */, 56339A3D12991A45000B6F2C /* GRMustacheTokenizerTest.m in Sources */, 56339A3E12991A4A000B6F2C /* GRMustacheTokenizer.m in Sources */, 56339AD912992E4F000B6F2C /* GRMustacheTemplateParser.m in Sources */,