🐙 Templated web page generator for your git repositories
git clone https://github.com/m-col/gitja
Files | Refs | Readme | License

Commit a6171632c7bed6c70d9cf875f50cbd7d32e1e800
Parent: 433568bcb220a8deba4dfcc4af1771acfb1775a2
Author: mcol <mcol@posteo.net>
Date: 2021-12-04 16:41:40 +0300
Committer: mcol <mcol@posteo.net>
Committed: 2021-12-04 16:41:40 +0300

Docs: if folder contains 1 item, render its contents too

templates/docs/repo/file.html Modified

@@ -23,6 +23,18 @@
     {% endfor %}
   </tbody>
 </table>
+
+  {%- if length(file.contents) == 1 -%}
+    {%- set child = file.contents[0] -%}
+    {% if child.is_binary %}
+    (Child is binary)
+    {% else %}
+<pre id="blob">{% for line in split(child.contents, '\n') %}
+<a href="#l{{ loop.index }}" class="line" id="l{{ loop.index }}">{{ printf("%5v", loop.index) }}</a>  {{ line }}
+{% endfor %}</pre>
+    {% endif %}
+  {%- endif -%}
+
 {% else %}
   {% if file.is_binary %}
   (File is binary)