aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorslinderud <simen.linderud@gmail.com>2019-12-03 20:23:36 +0100
committerslinderud <simen.linderud@gmail.com>2019-12-03 20:23:36 +0100
commit920fa648837152255c0937b03ec373c13830da42 (patch)
tree71dd785d42b9b6a58b760c0ccee8e9c2a2c085cb /web
parentd0f6e569304efd0a98ca6810b5f26e4f0293112b (diff)
Template: bugfixes on templating.py. Added test template that uses API and created a readme
Diffstat (limited to 'web')
-rw-r--r--web/templates/test.conf17
1 files changed, 17 insertions, 0 deletions
diff --git a/web/templates/test.conf b/web/templates/test.conf
new file mode 100644
index 0000000..ce2fe0d
--- /dev/null
+++ b/web/templates/test.conf
@@ -0,0 +1,17 @@
+{# Fetches something simple from gondul #}
+{# Query parameters: ?switch=e1-1 #}
+
+{# Check if ?switch option is given#}
+{% if not options["switch"] %}
+ {# pretty print public/switches endpoint#}
+ {{ objects["public/switches"] | pprint }}
+{% else %}
+ {# sets sw variable using the query parameter #}
+ {% set sw = options["switch"] %}
+{% endif %}
+{% if sw %}
+ {# find the correct switch from public/switches api endpoint using query paramter#}
+ {% set switch = objects["public/switches"].switches[sw] %}
+ {# pretty print info in api #}
+ {{ switch | tojson }}
+{% endif %}