From 675aab47125254e83de4d2557d5396165f44cc90 Mon Sep 17 00:00:00 2001 From: Fabio Date: Tue, 17 Oct 2017 20:50:35 +0200 Subject: [PATCH] Make environment variables available in templates --- dotdrop/templategen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dotdrop/templategen.py b/dotdrop/templategen.py index a362f00..d84b9c1 100644 --- a/dotdrop/templategen.py +++ b/dotdrop/templategen.py @@ -6,7 +6,7 @@ jinja2 template generator import os import utils -from jinja2 import Environment, Template, FileSystemLoader +from jinja2 import Environment, FileSystemLoader BLOCK_START = '{%@@' BLOCK_END = '@@%}' @@ -48,12 +48,12 @@ class Templategen: length = len(self.base) + 1 try: template = self.env.get_template(src[length:]) - content = template.render(profile=profile) + content = template.render(profile=profile, env=os.environ) except UnicodeDecodeError: data = self._read_bad_encoded_text(src) template = self.env.from_string(data) + content = template.render(profile=profile, env=os.environ) - content = template.render(profile=profile) content = content.encode('UTF-8') return content