def _render_jinja_template(template_dir, filename, jinja_vars):
"""
Renders a jinja template.
Sceptre supports passing sceptre_user_data to JSON and YAML
CloudFormation templates using Jinja2 templating.
:param template_dir: The directory containing the template.
:type template_dir: str
:param filename: The name of the template file.
:type filename: str
:param jinja_vars: Dict of variables to render into the template.
:type jinja_vars: dict
:returns: The body of the CloudFormation template.
:rtype: string
"""
logger = logging.getLogger(__name__)
logger.debug("%s Rendering CloudFormation template", filename)
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(template_dir),
undefined=jinja2.StrictUndefined
)
template = env.get_template(filename)
body = template.render(**jinja_vars)
return body
评论列表
文章目录