From e39d4d389785d65efc4edeb23a07992584112db5 Mon Sep 17 00:00:00 2001 From: Graham Welch Date: Tue, 15 Dec 2015 15:54:35 -0800 Subject: [PATCH] Add support for Template Outputs. Outputs can be referenced using normal reference syntax. --- expandybird/expansion/expansion.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/expandybird/expansion/expansion.py b/expandybird/expansion/expansion.py index 447a8a219..3b5e590a0 100755 --- a/expandybird/expansion/expansion.py +++ b/expandybird/expansion/expansion.py @@ -307,10 +307,19 @@ def ExpandTemplate(resource, imports, env, validate_schema=False): source_file, 'Unable to find source file %s in imports.' % (source_file)) - # source_file could be a short version of the template (say github short name) - # so we need to potentially map this into the fully resolvable name. - if 'path' in imports[source_file] and imports[source_file]['path']: - path = imports[source_file]['path'] + if isinstance(imports[source_file], dict): + # This code path assumes a different structure for the 'imports' param. + # Map of String (name) to Dict ('path', 'content'). + # + # source_file could be a short version of the template + # (say github short name) + # so we need to potentially map this into the fully resolvable name. + if 'path' in imports[source_file] and imports[source_file]['path']: + path = imports[source_file]['path'] + content = imports[source_file]['content'] + else: + path = source_file + content = imports[source_file] resource['imports'] = SimpleImportMap(imports) @@ -332,11 +341,11 @@ def ExpandTemplate(resource, imports, env, validate_schema=False): if path.endswith('jinja') or path.endswith('yaml'): expanded_template = ExpandJinja( - source_file, imports[source_file]['content'], resource, imports) + source_file, content, resource, imports) elif path.endswith('py'): # This is a Python template. expanded_template = ExpandPython( - imports[source_file]['content'], source_file, resource) + content, source_file, resource) else: # The source file is not a jinja file or a python file. # This in fact should never happen due to the IsTemplate check above.