Skip to content

Instantly share code, notes, and snippets.

@stevenhuey
Created September 9, 2013 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenhuey/6497668 to your computer and use it in GitHub Desktop.
Save stevenhuey/6497668 to your computer and use it in GitHub Desktop.
Barista Markdown Demo
-(void)willSendResponse:(BARResponse*)response
forRequest:(BARRequest*)request
forConnection:(BARConnection*)connection
continueHandler:(void (^)(void))handler
{
NSString* viewName = [response customValueForKey:@"BARTemplateView"];
if (viewName)
{
NSURL *viewURL = [[self.viewsDirectoryURL URLByAppendingPathComponent:viewName] URLByAppendingPathExtension:[[self class] templateFileExtension]];
NSString* fileAsString = [NSString stringWithContentsOfURL:viewURL
encoding:NSUTF8StringEncoding
error:NULL];
NSString* content = [MMMarkdown HTMLStringWithMarkdown:fileAsString error:NULL];
NSData *contentData = [content dataUsingEncoding:NSUTF8StringEncoding];
response.responseData = contentData;
}
handler();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment