Permalink
Browse files

runtime.md guide focuses on valueForKey:, description, and NSFastEnum…

…eration protocol
  • Loading branch information...
groue committed May 4, 2012
1 parent dd8f13e commit d31d8cf1cd3f0bd3fd5430e312eca1174f74cdda
Showing with 13 additions and 15 deletions.
  1. +13 −15 Guides/runtime.md
View
@@ -3,30 +3,28 @@
GRMustache runtime
==================
-GRMustache rendering is the combination of a template and of an object that will provide the data. This guide describes this interaction in detail.
+## Overview
-Generally speaking, GRMustache will look for values in your data objects through the standard Key-Value Coding `valueForKey:` method.
+`valueForKey:`, `description`, `<NSFastEnumeration>`.
+
+Those are the only interfaces that you have to care about when providing data to GRMustache.
-You can thus provide rendering methods with NSDictionary instances, or custom objects with properties or methods whose name match the keys in the template tags.
+- `valueForKey:` is the standard [Key-Value Coding](http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/KeyValueCoding.html) method, that GRMustache invokes when looking for the data that will be rendered. Basically, for a `{{name}}` tag to be rendered, all you need to provide is an NSDictionary with the `@"name"` key, or an object declaring the `name` property.
-```objc
-// This template waits for a `name` key:
-GRMustacheTemplate *template = [GRMustacheTemplate templateFromString:@"{{name}}" error:NULL];
+- `description` is the standard [NSObject](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html) method, that GRMustache invokes when rendering the data it has fetched from `valueForKey:`. Most classes of Apple frameworks already have sensible implementations of `description`: NSString, NSNumber, etc. You generally won't have to think a lot about it.
-// Those two objects provide this `name` key:
-NSDictionary *dictionary = [NSDictionary dictionaryWithObject:@"dictionary" forKey:@"name"];
-Person *arthur = [Person personWithName:@"arthur"];
+- `NSFastEnumeration` is the standard protocol for [enumerable objects](http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocFastEnumeration.html). The most obvious enumerable is NSArray. There are others, and you may provide your own. Objects that conform to the `NSFastEnumeration` protocol are the base of GRMustache loops. You'll read more on this topic in the [loops.md](runtime/loops.md) guide.
-// "dictionary"
-[template renderObject:dictionary];
+You do not need to know more in order to talk to GRMustache.
-// "arthur"
-[template renderObject:arthur];
-```
+
+## In Detail
+
+Mustache does a little more than rendering plain `{{tags}}`. Let's review Mustache features and how GRMustache help you leverage them.
- [context_stack.md](runtime/context_stack.md)
- This guide digs into the key lookup mechanism.
+ This guide digs into Mustache `{{#sections}}`, and the key lookup mechanism.
- [loops.md](runtime/loops.md)

0 comments on commit d31d8cf

Please sign in to comment.