Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.