Skip to content

Commit

Permalink
foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
Light-Beacon committed Oct 16, 2024
1 parent 42febfc commit 6949ebd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions Modules/ForEach.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6949ebd

Please sign in to comment.