mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Added prototype variables
commit_hash:11d2829198ab483f46383db0ee431f93abae147a
This commit is contained in:
@@ -7,12 +7,13 @@ extension DivCollectionItemBuilder {
|
||||
mappedBy modificator: (Div, Block, DivBlockModelingContext) -> T
|
||||
) -> [T] {
|
||||
let items = resolveData(context.expressionResolver) ?? []
|
||||
return items.enumerated().compactMap { index, item in
|
||||
return items.enumerated().compactMap { index, item -> T? in
|
||||
let itemDict = item as? DivDictionary ?? [:]
|
||||
let prototypeContext = context.modifying(
|
||||
prototypeParams: PrototypeParams(
|
||||
index: index,
|
||||
variableName: dataElementName,
|
||||
value: (item as? DivDictionary) ?? [:]
|
||||
value: itemDict
|
||||
)
|
||||
)
|
||||
let prototype = prototypes
|
||||
@@ -27,6 +28,10 @@ extension DivCollectionItemBuilder {
|
||||
overridenId: id,
|
||||
pathSuffix: String(index)
|
||||
)
|
||||
itemContext.variablesStorage.initializeIfNeeded(path: itemContext.path, variables: [
|
||||
DivVariableName(rawValue: dataElementName): .dict(itemDict),
|
||||
"index": .integer(index),
|
||||
])
|
||||
do {
|
||||
return try modifyError({
|
||||
DivBlockModelingError($0.message, path: itemContext.path)
|
||||
|
||||
Reference in New Issue
Block a user