Commit 91fedb03 authored by Ad Schellevis's avatar Ad Schellevis

(configd) add toList method to template helpers.

Using helpers.toList('parent.tag') makes it explicit that we expect an item to be a list and solves issues with lists containing only one item.
parent 33136c90
......@@ -66,6 +66,19 @@ class Helpers(object):
else:
return False
def toList(self,tag):
""" if an item should be a list of items (repeating tag), use this method to make sure that we always return
a list. The configuration doesn't know if a non repeating item is supposed to be a list of items, this makes
it explicit.
:param tag: tag in dot notation (section.item)
:return: []
"""
result = self.getNodeByTag(tag)
if type(result) == list:
return result
else:
# wrap result
return [result]
def getUUIDtag(self, uuid):
""" retrieve tag name of registered uuid, returns __not_found__ if none available
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment