From f72460a0f8be35f9a402f4768a5c584bcfe4839c Mon Sep 17 00:00:00 2001 From: stijnvanhoey Date: Wed, 6 Dec 2017 20:20:31 +0100 Subject: [PATCH 1/5] Convert to jinja2 API --- build/build.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build/build.py b/build/build.py index 1265eaa..d5260dd 100644 --- a/build/build.py +++ b/build/build.py @@ -5,13 +5,14 @@ # import io +import os import re import csv import sys import codecs from urllib import request -from Cheetah.Template import Template +from jinja2 import FileSystemLoader, Environment NAMESPACES = { 'http://rs.tdwg.org/dwc/iri/' : 'dwciri', @@ -244,7 +245,7 @@ class DwcDigester(object): Parameters ----------- html_template : str - relative path and filename to the [Cheetah3](http://cheetahtemplate.org/) compatible + relative path and filename to the Jinja2 compatible template html_output : str relative path and filename to write the resulting index.html @@ -252,7 +253,10 @@ class DwcDigester(object): data = {} data["class_groups"] = self.template_data - html = Template(file=html_template, searchList=[data]) + + env = Environment(loader = FileSystemLoader(os.path.dirname(html_template))) + template = env.get_template(os.path.basename(html_template)) + html = template.render(data) index_page = open(html_output, "w") index_page.write(str(html)) From e5a00fee8350bbf6f2a3ab23b70c560b9e88bf00 Mon Sep 17 00:00:00 2001 From: stijnvanhoey Date: Wed, 6 Dec 2017 20:20:54 +0100 Subject: [PATCH 2/5] Update to jinja2 templating syntax --- build/config/index.tmpl | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build/config/index.tmpl b/build/config/index.tmpl index caf2964..f1922ed 100644 --- a/build/config/index.tmpl +++ b/build/config/index.tmpl @@ -4,7 +4,7 @@ Darwin Core quick reference guide - +