diff options
author | Simen Linderud <simen.linderud@gmail.com> | 2019-12-08 15:55:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-08 15:55:10 +0100 |
commit | 4dece982e5630dd57d49a10bd043b1e21da1b669 (patch) | |
tree | 6b94e93e30eb75bb149ca5dd7101d505e7d462ce /web | |
parent | 96fa1c1278850113cbbb86e098f3ec74d4fa61fd (diff) | |
parent | e3f94592109a476426b6c2945c4a8a8943f572ad (diff) |
Merge pull request #214 from slinderud/master
Templating: improved templating.py, added readme with examples, and a test template that uses the API
Diffstat (limited to 'web')
-rw-r--r-- | web/templates/test.conf | 17 |
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 %} |