]> granicus.if.org Git - graphviz/commitdiff
Use jinja2.PackageLoader
authorMark Hansen <mark@markhansen.co.nz>
Tue, 2 Jun 2020 11:25:54 +0000 (21:25 +1000)
committerMark Hansen <mark@markhansen.co.nz>
Wed, 3 Jun 2020 10:41:42 +0000 (20:41 +1000)
This resolves the path to the templates/ folder relative to the python
package (templates.py).

The FileSystemLoader was relative to current working directory.

After this, it doesn't matter what your current working directory is.

doc/infosrc/templates.py

index c3639aa4b1d89bdf016cf39d7ac7942ae3475796..5b920c1a24383a3c0b9af1c4b711db7ad02bdcfc 100644 (file)
@@ -3,7 +3,10 @@ import jinja2
 def env():
   return jinja2.Environment(
       # Load template files from ./templates/
-      loader=jinja2.FileSystemLoader('templates'),
+      loader=jinja2.PackageLoader(
+          package_name='templates',
+          package_path='templates',
+      ),
       # Auto-HTML-escape any html or xml files.
       autoescape=jinja2.select_autoescape(['html', 'xml', 'html.j2', 'xml.j2']),
       # Whitespace control