aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt
blob: 2f17183d6e679755322d8ac00656933dbc700985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package org.jetbrains.dokka.base.renderers.html.innerTemplating

public class DefaultTemplateModelMerger : TemplateModelMerger {
    override fun invoke(
        factories: List<TemplateModelFactory>,
        buildModel: TemplateModelFactory.() -> TemplateMap
    ): TemplateMap {
        val mapper = mutableMapOf<String, Any?>()
        factories.map(buildModel).forEach { partialModel ->
            partialModel.forEach { (k, v) ->
                mapper[k] = v
            }
        }
        return mapper
    }
}