1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 20:54:51 +00:00

Merge pull request #16 from s0undt3ch/master

Don't blindly sum 1 to get a relative path
This commit is contained in:
deadc0de
2018-01-05 08:52:01 +01:00
committed by GitHub

View File

@@ -21,7 +21,7 @@ COMMENT_END = '@@#}'
class Templategen:
def __init__(self, base='.'):
self.base = base
self.base = base.rstrip(os.sep)
loader = FileSystemLoader(self.base)
self.env = Environment(loader=loader,
trim_blocks=True, lstrip_blocks=True,
@@ -47,9 +47,9 @@ class Templategen:
return self._handle_text_file(src, profile)
def _handle_text_file(self, src, profile):
length = len(self.base) + 1
template_rel_path = src.split(self.base)[-1]
try:
template = self.env.get_template(src[length:])
template = self.env.get_template(template_rel_path)
content = template.render(profile=profile, env=os.environ)
except UnicodeDecodeError:
data = self._read_bad_encoded_text(src)