Answer the question
In order to leave comments, you need to log in
jinja2 no loader for this environment error?
Reading template from file, template directory and name are correct, template object is created.
Here is the code.
import markdown
import os
import hashlib
from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
print(os.listdir("../templates"))
loader = FileSystemLoader("../templates")
print (loader)
env = Environment(loader)
template = env.get_template("post")
files = os.listdir("docs")
def isChange(item):
if True:
return True
return False
def posts_create(directory,out):#,loader,template,env):
for item in directory:
filename = item[0:-3]
with open(directory+"/"+item,"r",encoding = "utf-8") as f:
with open (out+"/"+filename+".html","w+",encoding = "utf-8") as html:
# вывод шаблонизатора +
data = {"header":f.readline()[2:], "content":markdown.markdown(f.read())}
html.write(template.render(data))
posts_create(files,"../days")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question