Skip to content

Instantly share code, notes, and snippets.

@groue
Created September 22, 2012 11:04
Show Gist options
  • Save groue/3765846 to your computer and use it in GitHub Desktop.
Save groue/3765846 to your computer and use it in GitHub Desktop.
GRMustache: variable tag that renders a dynamic partial
{{#items}}
- {{link}}
{{/items}}
id data = @{
@"items": @[
@{ // movie
@"url": @"/movies/123",
@"title": @"Citizen Kane",
@"link": [GRMustacheTemplate templateFromResource:@"movie_link" bundle:nil error:NULL],
},
@{ // director
@"url": @"/people/321",
@"firstName": @"Orson",
@"lastName": @"Welles",
@"link": [GRMustacheTemplate templateFromResource:@"person_link" bundle:nil error:NULL],
}
]
};
NSString *rendering = [GRMustacheTemplate renderObject:data
fromResource:@"base"
bundle:nil
error:NULL];
- <a href="/movies/123">Citizen Kane</a>
- <a href="/people/321">Orson Welles</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment