GRMustache Class Reference
Inherits from | NSObject |
Declared in | GRMustache.h |
Overview
The GRMustache class provides with global-level information and configuration of the GRMustache library.
Tasks
Getting the GRMustache version
-
+ version
The version of GRMustache as a GRMustacheVersion struct.
Preventing NSUndefinedKeyException in Development configuration
-
+ preventNSUndefinedKeyExceptionAttack
Have GRMustache avoid most
NSUndefinedKeyExceptions
when rendering templates.
Standard Library
-
+ standardLibrary
The GRMustache standard library.
Building rendering objects
-
+ renderingObjectForObject:
Returns a rendering object that is able to render the argument object for the various Mustache tags.
-
+ renderingObjectWithBlock:
Returns a rendering object that renders with the provided block.
Class Methods
preventNSUndefinedKeyExceptionAttack
Have GRMustache avoid most NSUndefinedKeyExceptions
when rendering
templates.
+ (void)preventNSUndefinedKeyExceptionAttack
Availability
Discussion
The rendering of a GRMustache template can lead to many
NSUndefinedKeyExceptions
to be raised, because of the heavy usage of
Key-Value Coding. Those exceptions are nicely handled by GRMustache, and are
part of the regular rendering of a template.
Unfortunately, when debugging a project, developers usually set their debugger to stop on every Objective-C exceptions. GRMustache rendering can thus become a huge annoyance. This method prevents it.
You’ll get a slight performance hit, so you’d probably make sure this call does not enter your Release configuration.
One way to achieve this is to add -DDEBUG
to the “Other C Flags” setting of
your development configuration, and to wrap the
preventNSUndefinedKeyExceptionAttack
method call in a #if block, like:
#ifdef DEBUG
[GRMustache preventNSUndefinedKeyExceptionAttack];
#endif
Companion guide: https://github.com/groue/GRMustache/blob/master/Guides/runtime.md
Declared In
GRMustache.h
renderingObjectForObject:
Returns a rendering object that is able to render the argument object for the various Mustache tags.
+ (id<GRMustacheRendering>)renderingObjectForObject:(id)object
Parameters
- object
An object.
Return Value
A rendering object able to render the argument.
Availability
Discussion
If object already conforms to the GRMustacheRendering protocol, this method returns object itself: it is already able to render.
For other values, including nil
, this method returns a rendering object
that provides the default GRMustache rendering.
See Also
GRMustacheRendering protocol
Declared In
GRMustache.h
renderingObjectWithBlock:
Returns a rendering object that renders with the provided block.
+ (id<GRMustacheRendering>)renderingObjectWithBlock:(NSString *( ^ ) ( GRMustacheTag *tag , GRMustacheContext *context , BOOL *HTMLSafe , NSError **error ))block
Parameters
- block
A block that follows the semantics of the
renderForMustacheTag:context:HTMLSafe:error: method defined by the GRMustacheRendering protocol. See the documentation of this method.
Return Value
A rendering object
Availability
See Also
GRMustacheRendering protocol
Declared In
GRMustache.h