template.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:sceptre 作者: cloudreach 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号