Skip to content
Browse files

v1.12.0

  • Loading branch information...
1 parent a344960 commit 299d3b153b82f968babe609d0d5664bdad5f38a2 @groue committed Mar 4, 2012
Showing with 5,505 additions and 105 deletions.
  1. +1 −1 Classes/GRMustacheVersion.h
  2. +4 −4 README.md
  3. +9 −0 RELEASE_NOTES.md
  4. +323 −0 SampleCode/NumberFormatting/NumberFormatting.xcodeproj/project.pbxproj
  5. +29 −0 SampleCode/NumberFormatting/NumberFormatting/GRAppDelegate.h
  6. +137 −0 SampleCode/NumberFormatting/NumberFormatting/GRAppDelegate.m
  7. +34 −0 SampleCode/NumberFormatting/NumberFormatting/NumberFormatting-Info.plist
  8. +7 −0 SampleCode/NumberFormatting/NumberFormatting/NumberFormatting-Prefix.pch
  9. +29 −0 SampleCode/NumberFormatting/NumberFormatting/en.lproj/Credits.rtf
  10. +2 −0 SampleCode/NumberFormatting/NumberFormatting/en.lproj/InfoPlist.strings
  11. +4,587 −0 SampleCode/NumberFormatting/NumberFormatting/en.lproj/MainMenu.xib
  12. +14 −0 SampleCode/NumberFormatting/NumberFormatting/main.m
  13. +11 −0 SampleCode/NumberFormatting/NumberFormatting/template.mustache
  14. +0 −14 guides/date_formatting.md
  15. +0 −70 guides/number_formatting.md
  16. +3 −0 guides/runtime.md
  17. +8 −0 guides/runtime/delegate.md
  18. +2 −2 guides/runtime/helpers.md
  19. +2 −0 include/GRMustache.h
  20. +188 −2 include/GRMustacheAvailabilityMacros.h
  21. +2 −2 include/GRMustacheDateFormatterHelper.h
  22. +32 −0 include/GRMustacheInvocation.h
  23. +20 −1 include/GRMustacheLambda.h
  24. +2 −2 include/GRMustacheNumberFormatterHelper.h
  25. +2 −0 include/GRMustacheSection.h
  26. +11 −2 include/GRMustacheTemplate.h
  27. +35 −0 include/GRMustacheTemplateDelegate.h
  28. +9 −3 include/GRMustacheTemplateLoader.h
  29. +2 −2 include/GRMustacheVersion.h
  30. BIN lib/libGRMustache1-ios3.a
  31. BIN lib/libGRMustache1-ios4.a
  32. BIN lib/libGRMustache1-macosx10.6.a
View
2 Classes/GRMustacheVersion.h
@@ -40,5 +40,5 @@
@since v1.0
*/
-#define GRMUSTACHE_PATCH_VERSION 2
+#define GRMUSTACHE_PATCH_VERSION 0
View
8 README.md
@@ -21,17 +21,17 @@ What you get
**Compatibility with previous GRMustache versions**: update GRMustache, enjoy [performance improvements](https://github.com/groue/GRMustacheBenchmark) and bugfixes, and don't change a line of your code. You may get harmless deprecation warnings, though. Check the [release notes](GRMustache/blob/master/RELEASE_NOTES.md).
-**Number and date formatting.** Handy, and built-in.
-
**Documentation**: GRMustache online documentation is provided as guides:
- [guides/embedding.md](GRMustache/blob/master/guides/embedding.md): how to embed GRMustache in your Xcode projects
- [guides/templates.md](GRMustache/blob/master/guides/templates.md): how to parse and render templates
- [guides/runtime.md](GRMustache/blob/master/guides/runtime.md): how to provide data to templates
-- [guides/number_formatting.md](GRMustache/blob/master/guides/number_formatting.md): how to format numbers
-- [guides/date_formatting.md](GRMustache/blob/master/guides/date_formatting.md): how to format dates
- [guides/forking.md](GRMustache/blob/master/guides/forking.md): how GRMustache is organized
+**Sample code**: because some tasks are easier to do with some guidelines.
+
+- [SampleCode/NumberFormatting](GRMustache/blob/master/SampleCode/NumberFormatting): how to use NSNumberFormatter instances to format numbers in sections of your templates.
+
Usage
-----
View
9 RELEASE_NOTES.md
@@ -3,6 +3,15 @@ GRMustache Release Notes
You can compare the performances of GRMustache version at https://github.com/groue/GRMustacheBenchmark.
+## v1.12
+
+- **GRMustacheTemplateDelegate protocol**
+
+Deprecated classes:
+
+- `GRMustacheNumberFormatterHelper`
+- `GRMustacheDateFormatterHelper`
+
## v1.11.2
BOOL property custom getters can be used to control boolean sections.
View
323 SampleCode/NumberFormatting/NumberFormatting.xcodeproj/project.pbxproj
@@ -0,0 +1,323 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 56E540BF1503E2B9002F5D6E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56E540BE1503E2B9002F5D6E /* Cocoa.framework */; };
+ 56E540C91503E2B9002F5D6E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 56E540C71503E2B9002F5D6E /* InfoPlist.strings */; };
+ 56E540CB1503E2BA002F5D6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 56E540CA1503E2BA002F5D6E /* main.m */; };
+ 56E540CF1503E2BA002F5D6E /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 56E540CD1503E2BA002F5D6E /* Credits.rtf */; };
+ 56E540D21503E2BA002F5D6E /* GRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 56E540D11503E2BA002F5D6E /* GRAppDelegate.m */; };
+ 56E540D51503E2BA002F5D6E /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 56E540D31503E2BA002F5D6E /* MainMenu.xib */; };
+ 56E540DE1503E36C002F5D6E /* libGRMustache1-macosx10.6.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56E540DD1503E36C002F5D6E /* libGRMustache1-macosx10.6.a */; };
+ 56E540E01503E3D9002F5D6E /* template.mustache in Resources */ = {isa = PBXBuildFile; fileRef = 56E540DF1503E3D9002F5D6E /* template.mustache */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 56E540BA1503E2B9002F5D6E /* NumberFormatting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NumberFormatting.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 56E540BE1503E2B9002F5D6E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
+ 56E540C11503E2B9002F5D6E /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
+ 56E540C21503E2B9002F5D6E /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
+ 56E540C31503E2B9002F5D6E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 56E540C61503E2B9002F5D6E /* NumberFormatting-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "NumberFormatting-Info.plist"; sourceTree = "<group>"; };
+ 56E540C81503E2B9002F5D6E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 56E540CA1503E2BA002F5D6E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 56E540CC1503E2BA002F5D6E /* NumberFormatting-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NumberFormatting-Prefix.pch"; sourceTree = "<group>"; };
+ 56E540CE1503E2BA002F5D6E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
+ 56E540D01503E2BA002F5D6E /* GRAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GRAppDelegate.h; sourceTree = "<group>"; };
+ 56E540D11503E2BA002F5D6E /* GRAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GRAppDelegate.m; sourceTree = "<group>"; };
+ 56E540D41503E2BA002F5D6E /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
+ 56E540DC1503E36C002F5D6E /* GRMustache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GRMustache.h; path = include/GRMustache.h; sourceTree = "<group>"; };
+ 56E540DD1503E36C002F5D6E /* libGRMustache1-macosx10.6.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libGRMustache1-macosx10.6.a"; path = "lib/libGRMustache1-macosx10.6.a"; sourceTree = "<group>"; };
+ 56E540DF1503E3D9002F5D6E /* template.mustache */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = template.mustache; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 56E540B71503E2B9002F5D6E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 56E540BF1503E2B9002F5D6E /* Cocoa.framework in Frameworks */,
+ 56E540DE1503E36C002F5D6E /* libGRMustache1-macosx10.6.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 56E540AF1503E2B9002F5D6E = {
+ isa = PBXGroup;
+ children = (
+ 56E540DB1503E2D4002F5D6E /* GRMustache */,
+ 56E540C41503E2B9002F5D6E /* NumberFormatting */,
+ 56E540BD1503E2B9002F5D6E /* Frameworks */,
+ 56E540BB1503E2B9002F5D6E /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 56E540BB1503E2B9002F5D6E /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 56E540BA1503E2B9002F5D6E /* NumberFormatting.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 56E540BD1503E2B9002F5D6E /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 56E540BE1503E2B9002F5D6E /* Cocoa.framework */,
+ 56E540C01503E2B9002F5D6E /* Other Frameworks */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 56E540C01503E2B9002F5D6E /* Other Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 56E540C11503E2B9002F5D6E /* AppKit.framework */,
+ 56E540C21503E2B9002F5D6E /* CoreData.framework */,
+ 56E540C31503E2B9002F5D6E /* Foundation.framework */,
+ );
+ name = "Other Frameworks";
+ sourceTree = "<group>";
+ };
+ 56E540C41503E2B9002F5D6E /* NumberFormatting */ = {
+ isa = PBXGroup;
+ children = (
+ 56E540D01503E2BA002F5D6E /* GRAppDelegate.h */,
+ 56E540D11503E2BA002F5D6E /* GRAppDelegate.m */,
+ 56E540D31503E2BA002F5D6E /* MainMenu.xib */,
+ 56E540DF1503E3D9002F5D6E /* template.mustache */,
+ 56E540C51503E2B9002F5D6E /* Supporting Files */,
+ );
+ path = NumberFormatting;
+ sourceTree = "<group>";
+ };
+ 56E540C51503E2B9002F5D6E /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 56E540C61503E2B9002F5D6E /* NumberFormatting-Info.plist */,
+ 56E540C71503E2B9002F5D6E /* InfoPlist.strings */,
+ 56E540CA1503E2BA002F5D6E /* main.m */,
+ 56E540CC1503E2BA002F5D6E /* NumberFormatting-Prefix.pch */,
+ 56E540CD1503E2BA002F5D6E /* Credits.rtf */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 56E540DB1503E2D4002F5D6E /* GRMustache */ = {
+ isa = PBXGroup;
+ children = (
+ 56E540DC1503E36C002F5D6E /* GRMustache.h */,
+ 56E540DD1503E36C002F5D6E /* libGRMustache1-macosx10.6.a */,
+ );
+ name = GRMustache;
+ path = ../..;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 56E540B91503E2B9002F5D6E /* NumberFormatting */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 56E540D81503E2BA002F5D6E /* Build configuration list for PBXNativeTarget "NumberFormatting" */;
+ buildPhases = (
+ 56E540B61503E2B9002F5D6E /* Sources */,
+ 56E540B71503E2B9002F5D6E /* Frameworks */,
+ 56E540B81503E2B9002F5D6E /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = NumberFormatting;
+ productName = NumberFormatting;
+ productReference = 56E540BA1503E2B9002F5D6E /* NumberFormatting.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 56E540B11503E2B9002F5D6E /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ CLASSPREFIX = GR;
+ LastUpgradeCheck = 0430;
+ };
+ buildConfigurationList = 56E540B41503E2B9002F5D6E /* Build configuration list for PBXProject "NumberFormatting" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 56E540AF1503E2B9002F5D6E;
+ productRefGroup = 56E540BB1503E2B9002F5D6E /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 56E540B91503E2B9002F5D6E /* NumberFormatting */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 56E540B81503E2B9002F5D6E /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 56E540C91503E2B9002F5D6E /* InfoPlist.strings in Resources */,
+ 56E540CF1503E2BA002F5D6E /* Credits.rtf in Resources */,
+ 56E540D51503E2BA002F5D6E /* MainMenu.xib in Resources */,
+ 56E540E01503E3D9002F5D6E /* template.mustache in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 56E540B61503E2B9002F5D6E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 56E540CB1503E2BA002F5D6E /* main.m in Sources */,
+ 56E540D21503E2BA002F5D6E /* GRAppDelegate.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 56E540C71503E2B9002F5D6E /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 56E540C81503E2B9002F5D6E /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ 56E540CD1503E2BA002F5D6E /* Credits.rtf */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 56E540CE1503E2BA002F5D6E /* en */,
+ );
+ name = Credits.rtf;
+ sourceTree = "<group>";
+ };
+ 56E540D31503E2BA002F5D6E /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 56E540D41503E2BA002F5D6E /* en */,
+ );
+ name = MainMenu.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 56E540D61503E2BA002F5D6E /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 56E540D71503E2BA002F5D6E /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.7;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ 56E540D91503E2BA002F5D6E /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "NumberFormatting/NumberFormatting-Prefix.pch";
+ INFOPLIST_FILE = "NumberFormatting/NumberFormatting-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../lib\"",
+ );
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ 56E540DA1503E2BA002F5D6E /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "NumberFormatting/NumberFormatting-Prefix.pch";
+ INFOPLIST_FILE = "NumberFormatting/NumberFormatting-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../lib\"",
+ );
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 56E540B41503E2B9002F5D6E /* Build configuration list for PBXProject "NumberFormatting" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 56E540D61503E2BA002F5D6E /* Debug */,
+ 56E540D71503E2BA002F5D6E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 56E540D81503E2BA002F5D6E /* Build configuration list for PBXNativeTarget "NumberFormatting" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 56E540D91503E2BA002F5D6E /* Debug */,
+ 56E540DA1503E2BA002F5D6E /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 56E540B11503E2B9002F5D6E /* Project object */;
+}
View
29 SampleCode/NumberFormatting/NumberFormatting/GRAppDelegate.h
@@ -0,0 +1,29 @@
+// The MIT License
+//
+// Copyright (c) 2012 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 <Cocoa/Cocoa.h>
+
+@interface GRAppDelegate : NSObject <NSApplicationDelegate>
+
+@property (assign) IBOutlet NSWindow *window;
+
+@end
View
137 SampleCode/NumberFormatting/NumberFormatting/GRAppDelegate.m
@@ -0,0 +1,137 @@
+// The MIT License
+//
+// Copyright (c) 2012 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 "GRAppDelegate.h"
+#import "GRMustache.h"
+
+@interface GRAppDelegate() <GRMustacheTemplateDelegate>
+@property (nonatomic, retain) NSMutableArray *templateNumberFormatterStack;
+@end
+
+@implementation GRAppDelegate
+
+@synthesize window = _window;
+@synthesize templateNumberFormatterStack=_templateNumberFormatterStack;
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ /**
+ Our goal is to format all numbers in the {{#percent_format}} and
+ {{#decimal_format}} sections of template.mustache.
+
+ First, we attach a NSNumberFormatter instance to those sections. This is done
+ by setting NSNumberFormatter instances to corresponding keys in the data object
+ that we will render.
+ */
+
+ NSMutableDictionary *data = [NSMutableDictionary dictionary];
+
+ // Attach a percent NSNumberFormatter to the "percent_format" key
+ NSNumberFormatter *percentNumberFormatter = [[NSNumberFormatter alloc] init];
+ percentNumberFormatter.numberStyle = kCFNumberFormatterPercentStyle;
+ [data setObject:percentNumberFormatter forKey:@"percent_format"];
+
+ // Attach a decimal NSNumberFormatter to the "percent_format" key
+ NSNumberFormatter *decimalNumberFormatter = [[NSNumberFormatter alloc] init];
+ decimalNumberFormatter.numberStyle = kCFNumberFormatterDecimalStyle;
+ [data setObject:decimalNumberFormatter forKey:@"decimal_format"];
+
+ /**
+ We need a float to be rendered as the {{float}} tags of template.mustache.
+ */
+
+ // Attach a float to the "float" key
+ [data setObject:[NSNumber numberWithFloat:0.5] forKey:@"float"];
+
+
+ /**
+ Render. The formatting of numbers will happen in the
+ GRMustacheTemplateDelegate methods.
+ */
+
+ GRMustacheTemplate *template = [GRMustacheTemplate templateFromResource:@"template" bundle:nil error:NULL];
+ template.delegate = self;
+ NSString *result = [template renderObject:data];
+ NSLog(@"%@", result);
+}
+
+
+#pragma mark GRMustacheTemplateDelegate
+
+- (void)templateWillRender:(GRMustacheTemplate *)template
+{
+ /**
+ Prepare a stack of NSNumberFormatter objects.
+
+ Each time we'll enter a section that is attached to a NSNumberFormatter,
+ we'll enqueue this NSNumberFormatter in the stack. This is done in
+ [template:willRenderReturnValueOfInvocation:]
+ */
+ self.templateNumberFormatterStack = [NSMutableArray array];
+}
+
+- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation
+{
+ /**
+ The invocation object tells us which object is about to be rendered.
+ */
+ if ([invocation.returnValue isKindOfClass:[NSNumberFormatter class]])
+ {
+ /**
+ If it is a NSNumberFormatter, enqueue it in templateNumberFormatterStack.
+ */
+ [self.templateNumberFormatterStack addObject:invocation.returnValue];
+ }
+ else if (self.templateNumberFormatterStack.count > 0 && [invocation.returnValue isKindOfClass:[NSNumber class]])
+ {
+ /**
+ If it is a NSNumber, and if our templateNumberFormatterStack is not empty,
+ use the top NSNumberFormatter to format the number.
+
+ The invocation's returnValue can be set: this is the object that will be
+ rendered.
+ */
+ NSNumberFormatter *numberFormatter = self.templateNumberFormatterStack.lastObject;
+ invocation.returnValue = [numberFormatter stringFromNumber:(NSNumber *)invocation.returnValue];
+ }
+}
+
+- (void)template:(GRMustacheTemplate *)template didRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation
+{
+ /**
+ Make sure we dequeue NSNumberFormatters when we leave their scope.
+ */
+ if ([invocation.returnValue isKindOfClass:[NSNumberFormatter class]])
+ {
+ [self.templateNumberFormatterStack removeLastObject];
+ }
+}
+
+- (void)templateDidRender:(GRMustacheTemplate *)template
+{
+ /**
+ Final cleanup: release the stack created in templateWillRender:
+ */
+ self.templateNumberFormatterStack = nil;
+}
+
+@end
View
34 SampleCode/NumberFormatting/NumberFormatting/NumberFormatting-Info.plist
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.github.groue.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2012 __MyCompanyName__. All rights reserved.</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
View
7 SampleCode/NumberFormatting/NumberFormatting/NumberFormatting-Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'NumberFormatting' target in the 'NumberFormatting' project
+//
+
+#ifdef __OBJC__
+ #import <Cocoa/Cocoa.h>
+#endif
View
29 SampleCode/NumberFormatting/NumberFormatting/en.lproj/Credits.rtf
@@ -0,0 +1,29 @@
+{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\paperw9840\paperh8400
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
+
+\f0\b\fs24 \cf0 Engineering:
+\b0 \
+ Some people\
+\
+
+\b Human Interface Design:
+\b0 \
+ Some other people\
+\
+
+\b Testing:
+\b0 \
+ Hopefully not nobody\
+\
+
+\b Documentation:
+\b0 \
+ Whoever\
+\
+
+\b With special thanks to:
+\b0 \
+ Mom\
+}
View
2 SampleCode/NumberFormatting/NumberFormatting/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
View
4,587 SampleCode/NumberFormatting/NumberFormatting/en.lproj/MainMenu.xib
4,587 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
14 SampleCode/NumberFormatting/NumberFormatting/main.m
@@ -0,0 +1,14 @@
+//
+// main.m
+// NumberFormatting
+//
+// Created by Gwendal Roué on 04/03/12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, char *argv[])
+{
+ return NSApplicationMain(argc, (const char **)argv);
+}
View
11 SampleCode/NumberFormatting/NumberFormatting/template.mustache
@@ -0,0 +1,11 @@
+raw: {{float}}
+
+{{#percent_format}}
+percent: {{float}}
+{{/percent_format}}
+
+{{#decimal_format}}
+decimal: {{float}}
+{{/decimal_format}}
+
+raw: {{float}}
View
14 guides/date_formatting.md
@@ -1,14 +0,0 @@
-[up](../../../../GRMustache), [next](forking.md)
-
-Date formatting with GRMustacheDateFormatterHelper
-==================================================
-
-**This helper class allows you to format the dates in a section of your template.**
-
-It does not belong the the core GRMustache code, and as such must be imported separately:
-
- #import "GRMustacheDateFormatterHelper.h"
-
-Read [guides/number_formatting.md](number_formatting.md) documentation, because the principles are the same. You'll just provide a `NSDateFormatter` instead of a `NSNumberFormatter`.
-
-[up](../../../../GRMustache), [next](forking.md)
View
70 guides/number_formatting.md
@@ -1,70 +0,0 @@
-[up](../../../../GRMustache), [next](date_formatting.md)
-
-Number formatting with GRMustacheNumberFormatterHelper
-======================================================
-
-**This helper class allows you to format the numbers in a section of your template.**
-
-It does not belong the the core GRMustache code, and as such must be imported separately:
-
- #import "GRMustacheNumberFormatterHelper.h"
-
-Usage
------
-
-For instance, given the following template:
-
- raw: {{float}}
-
- {{#percent_format}}
- percent: {{float}}
- {{/percent_format}}
-
- {{#decimal_format}}
- decimal: {{float}}
- {{/decimal_format}}
-
-We would like the float value to be displayed as a percentage in the `percent_format` section, and as a decimal in the `decimal_format` section.
-
-We just have to create two `GRMustacheNumberFormatterHelper` objects, provide them with `NSNumberFormatter` instances, and attach them to the `percent_format` and `decimal_format` section names:
-
- #import "GRMustacheNumberFormatterHelper.h"
-
- // The percent formatter, and helper:
- NSNumberFormatter percentNumberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
- percentNumberFormatter.numberStyle = kCFNumberFormatterPercentStyle;
- id percentHelper = [GRMustacheNumberFormatterHelper helperWithNumberFormatter:percentNumberFormatter];
-
- // The decimal formatter, and helper:
- NSNumberFormatter decimalNumberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
- decimalNumberFormatter.numberStyle = kCFNumberFormatterDecimalStyle;
- id decimalHelper = [GRMustacheNumberFormatterHelper helperWithNumberFormatter:decimalNumberFormatter];
-
- // The rendered data:
- NSNumber *float = [NSNumber numberWithFloat:0.5];
- NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
- percentHelper, @"percent_format",
- decimalHelper, @"decimal_format",
- float, @"float",
- nil];
-
- // The final rendering (on a French system):
- // raw: 0.5
- // percent: 50 %
- // decimal: 0,5
- [template renderObject:data];
-
-Scope & Caveats
----------------
-
-GRMustacheNumberFormatterHelper does not format numbers in sub sections. For instance, if you plan to format numbers in a collection, make sure your formatter helper is invoked *inside* the collection section:
-
- {{#items}}
- {{#decimal_format}}
- {{float}}
- {{/decimal_format}}
- {{/items}}
-
-In the same fashion, it won't format numbers that are the result of a compound key path such as `foo.bar`.
-
-[up](../../../../GRMustache), [next](date_formatting.md)
View
3 guides/runtime.md
@@ -39,5 +39,8 @@ You can thus provide rendering methods with NSDictionary instances, or custom ob
Mustache has "lambda sections". These are sections that allow you to execute custom code, and implement nifty features like caching, filtering, whatever, on portions of your templates.
+- [delegate.md](runtime/delegate.md)
+
+ The GRMustacheTemplateDelegate protocol.
[up](../../../../GRMustache), [next](runtime/context_stack.md)
View
8 guides/runtime/delegate.md
@@ -0,0 +1,8 @@
+[up](../runtime.md), [next](../forking.md)
+
+GRMustacheTemplateDelegate protocol
+===================================
+
+TODO
+
+[up](../runtime.md), [next](../forking.md)
View
4 guides/runtime/helpers.md
@@ -1,4 +1,4 @@
-[up](../runtime.md), [next](../number_formatting.md)
+[up](../runtime.md), [next](delegate.md)
Helpers
=======
@@ -170,4 +170,4 @@ You may implement debugging sections:
return nil; // don't render anything
});
-[up](../runtime.md), [next](../number_formatting.md)
+[up](../runtime.md), [next](delegate.md)
View
2 include/GRMustache.h
@@ -157,7 +157,9 @@ typedef struct {
@end
#import "GRMustacheSection.h"
+#import "GRMustacheInvocation.h"
#import "GRMustacheTemplate.h"
+#import "GRMustacheTemplateDelegate.h"
#import "GRMustacheTemplateLoader.h"
#import "GRMustacheContext.h"
#import "GRMustacheLambda.h"
View
190 include/GRMustacheAvailabilityMacros.h
@@ -40,17 +40,18 @@
#define GRMUSTACHE_VERSION_1_9 1090
#define GRMUSTACHE_VERSION_1_10 1100
#define GRMUSTACHE_VERSION_1_11 1110
+#define GRMUSTACHE_VERSION_1_12 1120
/*
- * If max GRMustacheVersion not specified, assume 1.11
+ * If max GRMustacheVersion not specified, assume 1.12
*/
#ifndef GRMUSTACHE_VERSION_MAX_ALLOWED
-#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_11
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_12
#endif
/*
@@ -1345,3 +1346,188 @@
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER
+ *
+ * Used on declarations introduced in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MAX_ALLOWED < GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER UNAVAILABLE_ATTRIBUTE
+#elif GRMUSTACHE_VERSION_MIN_REQUIRED < GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER WEAK_IMPORT_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER_BUT_DEPRECATED
+ *
+ * Used on declarations introduced in GRMustache 1.12,
+ * and deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER_BUT_DEPRECATED AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.0,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.1,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_1_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.2,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_2_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.3,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_4_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.4,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_4_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_4_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_4_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_5_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.5,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_5_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_5_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_5_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_6_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.6,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_6_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_6_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_6_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_7_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.7,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_7_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_7_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_7_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.8,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.9,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_10_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.10,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_10_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_10_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_10_AND_LATER
+#endif
+
+/*
+ * AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12
+ *
+ * Used on declarations introduced in GRMustache 1.11,
+ * but later deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 DEPRECATED_ATTRIBUTE
+#else
+#define AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12 AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER
+#endif
+
+/*
+ * DEPRECATED_IN_GRMUSTACHE_VERSION_1_12_AND_LATER
+ *
+ * Used on types deprecated in GRMustache 1.12
+ */
+#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_12
+#define DEPRECATED_IN_GRMUSTACHE_VERSION_1_12_AND_LATER DEPRECATED_ATTRIBUTE
+#else
+#define DEPRECATED_IN_GRMUSTACHE_VERSION_1_12_AND_LATER
+#endif
+
+
+
+
+
+
View
4 include/GRMustacheDateFormatterHelper.h
@@ -28,6 +28,6 @@
@private
NSDateFormatter *_dateFormatter;
}
-@property (nonatomic, readonly, retain) NSDateFormatter *dateFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER;
-+ (id)helperWithDateFormatter:(NSDateFormatter *)dateFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER;
+@property (nonatomic, readonly, retain) NSDateFormatter *dateFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12;
++ (id)helperWithDateFormatter:(NSDateFormatter *)dateFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12;
@end
View
32 include/GRMustacheInvocation.h
@@ -0,0 +1,32 @@
+// The MIT License
+//
+// Copyright (c) 2012 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 <Foundation/Foundation.h>
+#import "GRMustacheAvailabilityMacros.h"
+
+@interface GRMustacheInvocation : NSObject {
+@private
+ id _returnValue;
+}
+@property (nonatomic, readonly) NSString *key AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+@property (nonatomic, retain) id returnValue AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+@end
View
21 include/GRMustacheLambda.h
@@ -23,26 +23,45 @@
#import <Foundation/Foundation.h>
#import "GRMustacheEnvironment.h"
#import "GRMustacheAvailabilityMacros.h"
+
@class GRMustacheSection;
@class GRMustacheContext;
+
+// =============================================================================
+#pragma mark - <GRMustacheHelper>
+
@protocol GRMustacheHelper<NSObject>
@required
- (NSString *)renderSection:(GRMustacheSection *)section withContext:(id)context AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER;
@end
+
#if GRMUSTACHE_BLOCKS_AVAILABLE
+
+// =============================================================================
+#pragma mark - GRMustacheBlockHelper
+
@interface GRMustacheBlockHelper: NSObject<GRMustacheHelper> {
@private
NSString *(^_block)(GRMustacheSection* section, id context);
}
+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section, id context))block AVAILABLE_GRMUSTACHE_VERSION_1_5_AND_LATER;
@end
+
+// =============================================================================
+#pragma mark -
+
typedef NSString *(^GRMustacheRenderingBlock)(GRMustacheSection*, GRMustacheContext*);
id GRMustacheLambdaBlockMake(GRMustacheRenderingBlock block) AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5;
+
+// =============================================================================
+#pragma mark -
+
typedef NSString *(^GRMustacheRenderer)(id object);
typedef id GRMustacheLambda;
GRMustacheLambda GRMustacheLambdaMake(NSString *(^block)(NSString *(^)(id object), id, NSString *)) AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3;
-#endif
+
+#endif /* if GRMUSTACHE_BLOCKS_AVAILABLE */
View
4 include/GRMustacheNumberFormatterHelper.h
@@ -28,6 +28,6 @@
@private
NSNumberFormatter *_numberFormatter;
}
-@property (nonatomic, readonly, retain) NSNumberFormatter *numberFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER;
-+ (id)helperWithNumberFormatter:(NSNumberFormatter *)numberFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER;
+@property (nonatomic, readonly, retain) NSNumberFormatter *numberFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12;
++ (id)helperWithNumberFormatter:(NSNumberFormatter *)numberFormatter AVAILABLE_GRMUSTACHE_VERSION_1_9_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_12;
@end
View
2 include/GRMustacheSection.h
@@ -24,6 +24,7 @@
#import "GRMustacheAvailabilityMacros.h"
@class GRMustacheInvocation;
+@class GRMustacheTemplate;
/**
`GRMustacheSection` is a class that is involved in mustache lambdas definition.
@@ -169,6 +170,7 @@
@interface GRMustacheSection: NSObject {
@private
GRMustacheInvocation *_invocation;
+ GRMustacheTemplate *_rootTemplate;
NSString *_baseTemplateString;
NSRange _range;
BOOL _inverted;
View
13 include/GRMustacheTemplate.h
@@ -23,6 +23,7 @@
#import <Foundation/Foundation.h>
#import "GRMustacheAvailabilityMacros.h"
#import "GRMustacheEnvironment.h"
+#import "GRMustacheTemplateDelegate.h"
#import "GRMustache.h"
/**
@@ -34,8 +35,11 @@
@private
NSArray *_elems;
GRMustacheTemplateOptions _options;
+ id<GRMustacheTemplateDelegate> _delegate;
}
+@property (nonatomic, assign) id<GRMustacheTemplateDelegate> delegate AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+
//////////////////////////////////////////////////////////////////////////////////////////
/// @name Parsing and Rendering Template Strings
@@ -159,6 +163,7 @@
+ (id)templateFromContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER;
#if !TARGET_OS_IPHONE || GRMUSTACHE_IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
/**
Parses a template file, and returns a compiled template.
@@ -187,7 +192,8 @@
*/
+ (id)templateFromContentsOfURL:(NSURL *)url error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER;
+ (id)templateFromContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_11_AND_LATER;
-#endif
+
+#endif /* if GRMUSTACHE_BLOCKS_AVAILABLE */
/**
Renders a context object from a file template.
@@ -204,7 +210,9 @@
+ (NSString *)renderObject:(id)object fromContentsOfFile:(NSString *)path error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_4_AND_LATER;
+ (NSString *)renderObject:(id)object fromContentsOfFile:(NSString *)path options:(GRMustacheTemplateOptions)options error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
+
#if !TARGET_OS_IPHONE || GRMUSTACHE_IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
/**
Renders a context object from a file template.
@@ -219,7 +227,8 @@
*/
+ (NSString *)renderObject:(id)object fromContentsOfURL:(NSURL *)url error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER;
+ (NSString *)renderObject:(id)object fromContentsOfURL:(NSURL *)url options:(GRMustacheTemplateOptions)options error:(NSError **)outError AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
-#endif
+
+#endif /* if GRMUSTACHE_BLOCKS_AVAILABLE */
//////////////////////////////////////////////////////////////////////////////////////////
View
35 include/GRMustacheTemplateDelegate.h
@@ -0,0 +1,35 @@
+// The MIT License
+//
+// Copyright (c) 2012 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 <Foundation/Foundation.h>
+#import "GRMustacheAvailabilityMacros.h"
+
+@class GRMustacheTemplate;
+@class GRMustacheInvocation;
+
+@protocol GRMustacheTemplateDelegate<NSObject>
+@optional
+- (void)templateWillRender:(GRMustacheTemplate *)template AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+- (void)templateDidRender:(GRMustacheTemplate *)template AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+- (void)template:(GRMustacheTemplate *)template willRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+- (void)template:(GRMustacheTemplate *)template didRenderReturnValueOfInvocation:(GRMustacheInvocation *)invocation AVAILABLE_GRMUSTACHE_VERSION_1_12_AND_LATER;
+@end
View
12 include/GRMustacheTemplateLoader.h
@@ -39,6 +39,7 @@
}
#if !TARGET_OS_IPHONE || GRMUSTACHE_IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
/**
@return A GRMustacheTemplateLoader instance
@param URL The URL of a directory
@@ -50,7 +51,8 @@
*/
+ (id)templateLoaderWithBaseURL:(NSURL *)URL AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER;
+ (id)templateLoaderWithBaseURL:(NSURL *)URL options:(GRMustacheTemplateOptions)options AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
-#endif
+
+#endif /* if GRMUSTACHE_BLOCKS_AVAILABLE */
/**
@return A GRMustacheTemplateLoader instance
@@ -76,6 +78,7 @@
+ (id)templateLoaderWithDirectory:(NSString *)path options:(GRMustacheTemplateOptions)options AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
#if !TARGET_OS_IPHONE || GRMUSTACHE_IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
/**
@return A GRMustacheTemplateLoader instance
@param URL The URL of a directory
@@ -92,7 +95,8 @@
*/
+ (id)templateLoaderWithBaseURL:(NSURL *)URL extension:(NSString *)ext AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER;
+ (id)templateLoaderWithBaseURL:(NSURL *)URL extension:(NSString *)ext options:(GRMustacheTemplateOptions)options AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
-#endif
+
+#endif /* if GRMUSTACHE_BLOCKS_AVAILABLE */
/**
@return A GRMustacheTemplateLoader instance
@@ -128,6 +132,7 @@
+ (id)templateLoaderWithDirectory:(NSString *)path extension:(NSString *)ext options:(GRMustacheTemplateOptions)options AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
#if !TARGET_OS_IPHONE || GRMUSTACHE_IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
+
/**
@return A GRMustacheTemplateLoader instance
@param URL The URL of a directory
@@ -145,7 +150,8 @@
*/
+ (id)templateLoaderWithBaseURL:(NSURL *)URL extension:(NSString *)ext encoding:(NSStringEncoding)encoding AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER;
+ (id)templateLoaderWithBaseURL:(NSURL *)URL extension:(NSString *)ext encoding:(NSStringEncoding)encoding options:(GRMustacheTemplateOptions)options AVAILABLE_GRMUSTACHE_VERSION_1_8_AND_LATER;
-#endif
+
+#endif /* if GRMUSTACHE_BLOCKS_AVAILABLE */
/**
@return A GRMustacheTemplateLoader instance
View
4 include/GRMustacheVersion.h
@@ -33,12 +33,12 @@
@since v1.0
*/
-#define GRMUSTACHE_MINOR_VERSION 11
+#define GRMUSTACHE_MINOR_VERSION 12
/**
The patch-level component of GRMustache version
@since v1.0
*/
-#define GRMUSTACHE_PATCH_VERSION 2
+#define GRMUSTACHE_PATCH_VERSION 0
View
BIN lib/libGRMustache1-ios3.a
Binary file not shown.
View
BIN lib/libGRMustache1-ios4.a
Binary file not shown.
View
BIN lib/libGRMustache1-macosx10.6.a
Binary file not shown.

0 comments on commit 299d3b1

Please sign in to comment.
Something went wrong with that request. Please try again.