diff --git a/Interfaces/__init__.py b/Interfaces/__init__.py index 62dbe27..3d44d9b 100644 --- a/Interfaces/__init__.py +++ b/Interfaces/__init__.py @@ -3,7 +3,7 @@ from Core.IO import file_reader, file_writer, read_string, write_string from Core.logger import Logger from Core.encode import encode_escape, decode_escape -from Core.utils.formatter import format_code +from Core.utils.formatter import format_code, get_card_prop from Core.i18n import locale from Core.utils import enable_by from Core.page import PageBase, FileBasedPage diff --git a/Modules/ForEach.py b/Modules/ForEach.py new file mode 100644 index 0000000..445d489 --- /dev/null +++ b/Modules/ForEach.py @@ -0,0 +1,13 @@ +from Interfaces import script,format_code, get_card_prop + +@script('ForEach') +def for_each_script(store_name,iter_item_name,itemoutput,**kwargs): + project = kwargs['proj'] + card = kwargs['card'] + iter_item = get_card_prop(card=card,attr_name=iter_item_name) + code = '' + for item in iter_item: + card_copy = card.copy() + card_copy[store_name] = item + code += format_code(itemoutput,card=card_copy,project=project,children_code='',err_output='false') + return code \ No newline at end of file