Skip to content

Instantly share code, notes, and snippets.

@mulle-nat
Created February 23, 2018 17:39
Show Gist options
  • Save mulle-nat/bfc82ed7822a823c0357179d92a3f835 to your computer and use it in GitHub Desktop.
Save mulle-nat/bfc82ed7822a823c0357179d92a3f835 to your computer and use it in GitHub Desktop.
MulleScion bidirectional
//
// Allow bidirectional communication with the template. After the template has run, you can pick out
// the global variables from `variables`. Might do this as a "standard" in the next version
//
@implementation MulleScionTemplate( VariableIO)
- (NSString *) descriptionWithTemplateFile:(NSObject <MulleScionStringOrURL> *) filename
dataSource:(id) dataSource
readWriteVariables:(NSMutableDictionary *) variables
{
MulleScionTemplate *template;
NSAutoreleasePool *pool;
NSMutableDictionary *tmp;
NSMutableString *output;
template = [[[MulleScionTemplate alloc] initWithContentsOfFile:filename] autorelease];
if( ! template)
return( nil);
pool = [NSAutoreleasePool new];
{
output = [[NSMutableString alloc] initWithCapacity:0x8000];
tmp = [template localVariablesWithDefaultValues:variables];
[variables setDictionary:tmp];
[template renderInto:output
localVariables:variables
dataSource:dataSource];
}
[pool release];
return( [output autorelease]);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment