GRMustacheContext Class Reference
Inherits from | NSObject |
Declared in | GRMustacheContext.h |
Overview
The GRMustacheContext represents a Mustache rendering context: it internally maintains two stacks:
Tasks
Creating Contexts
-
+ context
An empty rendering context.
-
+ contextWithObject:
Returns a context with object at the top of the context stack.
-
+ contextWithProtectedObject:
Returns a context with object at the top of the protected context stack.
-
+ contextWithTagDelegate:
Returns a context with tagDelegate at the top of the tag delegate stack.
Deriving New Contexts
-
– contextByAddingObject:
Returns a new rendering context that is the copy of the receiver, and the given object added at the top of the context stack.
-
– contextByAddingProtectedObject:
Returns a new rendering context that is the copy of the receiver, and the given object added at the top of the protected context stack.
-
– contextByAddingTagDelegate:
Returns a new rendering context that is the copy of the receiver, and the given object added at the top of the tag delegate stack.
-
– valueForMustacheExpression:error:
Evaluate the expression in the receiver context.
-
– valueForMustacheKey:
Returns the value stored in the context stack for the given key.
Class Methods
context
An empty rendering context.
+ (instancetype)context
Return Value
An empty rendering context.
Availability
Declared In
GRMustacheContext.h
contextWithObject:
+ (instancetype)contextWithObject:(id)object
Parameters
- object
An object
Return Value
A rendering context.
Availability
Discussion
If object conforms to the GRMustacheTemplateDelegate protocol, it is also made the top of the tag delegate stack.
Declared In
GRMustacheContext.h
contextWithProtectedObject:
+ (instancetype)contextWithProtectedObject:(id)object
Parameters
- object
An object
Return Value
A rendering context.
Availability
Discussion
Unlike contextWithObject:, this method does not put the object to the tag delegate stack if it conforms to the GRMustacheTemplateDelegate protocol.
Companion guide: https://github.com/groue/GRMustache/blob/master/Guides/protected_context.md
Declared In
GRMustacheContext.h
Instance Methods
contextByAddingObject:
Returns a new rendering context that is the copy of the receiver, and the given object added at the top of the context stack.
- (instancetype)contextByAddingObject:(id)object
Parameters
- object
An object
Return Value
A new rendering context.
Availability
Discussion
If object conforms to the GRMustacheTemplateDelegate protocol, it is also added at the top of the tag delegate stack.
Declared In
GRMustacheContext.h
contextByAddingProtectedObject:
Returns a new rendering context that is the copy of the receiver, and the given object added at the top of the protected context stack.
- (instancetype)contextByAddingProtectedObject:(id)object
Parameters
- object
An object
Return Value
A new rendering context.
Availability
Discussion
Unlike contextByAddingObject:, this method does not add the object to the tag delegate stack if it conforms to the GRMustacheTemplateDelegate protocol.
Companion guide: https://github.com/groue/GRMustache/blob/master/Guides/protected_context.md
Declared In
GRMustacheContext.h
contextByAddingTagDelegate:
Returns a new rendering context that is the copy of the receiver, and the given object added at the top of the tag delegate stack.
- (instancetype)contextByAddingTagDelegate:(id<GRMustacheTagDelegate>)tagDelegate
Parameters
- tagDelegate
A tag delegate
Return Value
A new rendering context.
Availability
Declared In
GRMustacheContext.h
valueForMustacheExpression:error:
Evaluate the expression in the receiver context.
- (id)valueForMustacheExpression:(NSString *)expression error:(NSError **)error
Availability
Discussion
This method can evaluate complex expressions such as user.name
or
uppercase(user.name)
.
See Also
Declared In
GRMustacheContext.h
valueForMustacheKey:
Returns the value stored in the context stack for the given key.
- (id)valueForMustacheKey:(NSString *)key
Availability
Discussion
If you want the value for an full expression such as user.name
or
uppercase(user.name)
, use the valueForMustacheExpression:error: method.
See Also
Declared In
GRMustacheContext.h