def load_templates(theme_path: str) -> Templates: jinja_env = Environment(loader=FileSystemLoader(theme_path)) jinja_env.filters['datetimeformat'] = __datetimeformat index_template = jinja_env.get_template('index.html') tag_template = jinja_env.get_template('tag.html') page_template = jinja_env.get_template('page.html') return Templates(index_template, page_template, tag_template)
def insert_template(name, description, markup): template_id = create_template_id(name) template = Templates(template_id, name, description, markup) conn = sqlite3.connect('template_data.db') # establish connection to the database c = conn.cursor() c.execute("""INSERT OR REPLACE INTO templates VALUES( :template_id, :name, :description, :markup ); """, {'template_id': template_id, 'name': name, 'description': description, 'markup': markup}) # exectute the query result = c.fetchall() conn.commit() # commit changes conn.close() # close connection print("Added template")