Skip to content

Commit

Permalink
Restore but deprecate GRMustacheTag.templateRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Mar 14, 2014
1 parent fdf9618 commit afb5dc4
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 10 deletions.
70 changes: 62 additions & 8 deletions RELEASE_NOTES.md
Expand Up @@ -73,16 +73,27 @@ GRMustacheTemplate and GRMustacheConfiguration have methods for inserting priori

```objc
@interface GRMustacheContext
+ (instancetype)contextWithProtectedObject:(id)object; // use contextWithPriorityObject instead
- (instancetype)contextByAddingProtectedObject:(id)object; // use contextByAddingPriorityObject instead

// use contextWithPriorityObject instead
+ (instancetype)contextWithProtectedObject:(id)object;

// use contextByAddingPriorityObject instead
- (instancetype)contextByAddingProtectedObject:(id)object;

@end

@interface GRMustacheTemplate
- (void)extendBaseContextWithProtectedObject:(id)object; // use extendBaseContextWithPriorityObject instead

// use extendBaseContextWithPriorityObject instead
- (void)extendBaseContextWithProtectedObject:(id)object;

@end

@interface GRMustacheConfiguration
- (void)extendBaseContextWithProtectedObject:(id)object; // use extendBaseContextWithPriorityObject instead

// Use extendBaseContextWithPriorityObject instead
- (void)extendBaseContextWithProtectedObject:(id)object;

@end
```
Expand Down Expand Up @@ -117,7 +128,10 @@ GRMustache implementation of inheritable templates is now closer from [hogan.js]
```objc
typedef NS_ENUM(NSUInteger, GRMustacheTagType) {
GRMustacheTagTypeOverridableSection; // constant not replaced
// This constant is not replaced.
GRMustacheTagTypeOverridableSection,
}
```

Expand All @@ -130,19 +144,59 @@ typedef NS_ENUM(NSUInteger, GRMustacheTagType) {

```objc
@interface GRMustache

+ (GRMustacheVersion)libraryVersion;

@end

@interface GRMustacheRendering

+ (id<GRMustacheRendering>)renderingObjectForObject:(id)object;
+ (id<GRMustacheRendering>)renderingObjectWithBlock:(NSString *(^)(GRMustacheTag *tag, GRMustacheContext *context, BOOL *HTMLSafe, NSError **error))block;

@end
```
**Removed APIS**
**Deprecated APIs**
```objc
@interface GRMustache
+ (GRMustacheVersion)version; // Use libraryVersion instead.
// Use `+[GRMustacheRendering renderingObjectForObject:]` instead.
+ (id<GRMustacheRendering>)renderingObjectForObject:(id)object;
// Use `+[GRMustacheRendering renderingObjectWithBlock:]` instead.
+ (id<GRMustacheRendering>)renderingObjectWithBlock:(NSString *(^)(GRMustacheTag *tag, GRMustacheContext *context, BOOL *HTMLSafe, NSError **error))block;
@end
@interface GRMustacheTag
// Replace `[tag.templateRepository templateFromString:... error:...]` by
// `[GRMustacheTemplate templateFromString:... error:...]`.
//
// Replace `[tag.templateRepository templateNamed:... error:...]` by explicit
// invocation of the targeted template repository.
@property (nonatomic, readonly) GRMustacheTemplateRepository *templateRepository;
@end
```

**Removed APIs**

```objc
@interface GRMustache

// Use +[GRMustache libraryVersion] instead.
+ (GRMustacheVersion)version;

@end

@interface GRMustacheContext
- (id)valueForMustacheExpression:(NSString *)string error:(NSError **)error; // This method used to be deprecated. Use hasValue:forMustacheExpression:error: instead.

// Use -[GRMustacheContext hasValue:forMustacheExpression:error:] instead.
- (id)valueForMustacheExpression:(NSString *)string error:(NSError **)error;

@end
```
Expand Down
3 changes: 1 addition & 2 deletions TODO.md
@@ -1,7 +1,6 @@
## TODO

- [ ] document dropped support for GRMustacheTag.templateRepository
- [X] have [GRMustacheTemplate templateFromString:error:] use current repository & content type, and remove public GRMustacheTag.templateRepository
- [X] have [GRMustacheTemplate templateFromString:error:] use current repository & content type, and deprecate GRMustacheTag.templateRepository
- [?] have GRMustacheTemplateRepository cache template from string (for faster rendering objects)
- [X] expose GRMustacheTemplate.templateRepository
- [X] document dropped support for garbage collection
Expand Down
16 changes: 16 additions & 0 deletions src/classes/GRMustacheTag.h
Expand Up @@ -24,6 +24,8 @@
#import "GRMustacheAvailabilityMacros.h"
#import "GRMustacheConfiguration.h"

@class GRMustacheTemplateRepository;

/**
* The types of Mustache tags
*
Expand Down Expand Up @@ -103,6 +105,20 @@ typedef NS_ENUM(NSUInteger, GRMustacheTagType) {
/// @name Methods Dedicated to the GRMustacheRendering Protocol
////////////////////////////////////////////////////////////////////////////////

/**
* This method is deprecated.
*
* Replace `[tag.templateRepository templateFromString:... error:...]` by
* `[GRMustacheTemplate templateFromString:... error:...]`.
*
* Replace `[tag.templateRepository templateNamed:... error:...]` by explicit
* invocation of the targeted template repository.
*
* @since v6.0
* @deprecated v7.0
*/
@property (nonatomic, readonly) GRMustacheTemplateRepository *templateRepository AVAILABLE_GRMUSTACHE_VERSION_7_0_AND_LATER_BUT_DEPRECATED;

/**
* Returns the rendering of the tag's inner content, rendering all inner
* Mustache tags with the rendering context argument.
Expand Down
5 changes: 5 additions & 0 deletions src/classes/GRMustacheTag.m
Expand Up @@ -95,6 +95,11 @@ - (NSString *)renderContentWithContext:(GRMustacheContext *)context HTMLSafe:(BO
return @"";
}

- (GRMustacheTemplateRepository *)templateRepository
{
return [GRMustacheRendering currentTemplateRepository];
}


#pragma mark - <GRMustacheTemplateComponent>

Expand Down
4 changes: 4 additions & 0 deletions src/classes/GRMustacheTag_private.h
Expand Up @@ -27,6 +27,7 @@

@class GRMustacheExpression;
@class GRMustacheContext;
@class GRMustacheTemplateRepository;

// Documented in GRMustacheTag.h
typedef NS_ENUM(NSUInteger, GRMustacheTagType) {
Expand All @@ -50,6 +51,9 @@ typedef NS_ENUM(NSUInteger, GRMustacheTagType) {
// Documented in GRMustacheTag.h
@property (nonatomic, readonly) NSString *innerTemplateString GRMUSTACHE_API_PUBLIC;

// Documented in GRMustacheTag.h
@property (nonatomic, readonly) GRMustacheTemplateRepository *templateRepository GRMUSTACHE_API_PUBLIC_BUT_DEPRECATED;

/**
* Returns the content type of the receiver.
*
Expand Down

0 comments on commit afb5dc4

Please sign in to comment.