mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-17 02:39:40 +00:00
add current item in forloop + global forloop reference (#2512)
This commit is contained in:
parent
49ef1aaa07
commit
bd72491d7d
4 changed files with 29 additions and 0 deletions
|
@ -198,6 +198,15 @@ class Block(BaseModel, abc.ABC):
|
|||
)
|
||||
|
||||
template_data[self.label] = block_reference_data
|
||||
|
||||
# inject the forloop metadata as global variables
|
||||
if "current_index" in block_reference_data:
|
||||
template_data["current_index"] = block_reference_data["current_index"]
|
||||
if "current_item" in block_reference_data:
|
||||
template_data["current_item"] = block_reference_data["current_item"]
|
||||
if "current_value" in block_reference_data:
|
||||
template_data["current_value"] = block_reference_data["current_value"]
|
||||
|
||||
return template.render(template_data)
|
||||
|
||||
@classmethod
|
||||
|
@ -948,7 +957,9 @@ class ForLoopBlock(Block):
|
|||
metadata: BlockMetadata = {
|
||||
"current_index": loop_idx,
|
||||
"current_value": loop_over_value,
|
||||
"current_item": loop_over_value,
|
||||
}
|
||||
workflow_run_context.update_block_metadata(self.label, metadata)
|
||||
workflow_run_context.update_block_metadata(loop_block.label, metadata)
|
||||
|
||||
original_loop_block = loop_block
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue