mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-16 16:45:16 +00:00
Make environment variables available in templates
This commit is contained in:
@@ -6,7 +6,7 @@ jinja2 template generator
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import utils
|
import utils
|
||||||
from jinja2 import Environment, Template, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
BLOCK_START = '{%@@'
|
BLOCK_START = '{%@@'
|
||||||
BLOCK_END = '@@%}'
|
BLOCK_END = '@@%}'
|
||||||
@@ -48,12 +48,12 @@ class Templategen:
|
|||||||
length = len(self.base) + 1
|
length = len(self.base) + 1
|
||||||
try:
|
try:
|
||||||
template = self.env.get_template(src[length:])
|
template = self.env.get_template(src[length:])
|
||||||
content = template.render(profile=profile)
|
content = template.render(profile=profile, env=os.environ)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
data = self._read_bad_encoded_text(src)
|
data = self._read_bad_encoded_text(src)
|
||||||
template = self.env.from_string(data)
|
template = self.env.from_string(data)
|
||||||
|
content = template.render(profile=profile, env=os.environ)
|
||||||
|
|
||||||
content = template.render(profile=profile)
|
|
||||||
content = content.encode('UTF-8')
|
content = content.encode('UTF-8')
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user