quince-science / KPI

Data quality reports for data processed in QuinCe
MIT License
0 stars 2 forks source link

New jinja template structure #10

Closed cla023 closed 4 years ago

cla023 commented 4 years ago

Use of child templates for general descriptions. The plan was to move all general descriptions (variable and kpi descriptions, and figure and table descriptions and captions) from the config file to various child html templates (from now on called child/children). The base html template (from now on called base) would then refer to different children to incorporate such descriptions as needed. Since the report sections (and subsections) consist of similar content in the same order (header, description of instrument/variable, figure and table descriptions, figure and tables with captions), the reference to various child files would happen in the for loops (the current base already contains such for loops).

It turns out this is not how the template inheritance in jinja works. The base does not refer to child templates, but one child refer to one base. Seems like this consept is more relevant for creating multiple webpages with the same layout (base) but different content (children).

There is however a feature to incorporate all content from a template file into the base, but this requires us to create one file per description. These files can be used in for loops. The for loops which creates the sections can select the correct parts to combine into one section. This is how we decided to solve this, and there is now several template files (one per description of something) which the base is extracting content from.

Macros (equivalent to python functions) are also been taken into use to avoid repetition in the base template file.