<https://docs.fritz2.dev/StylingDSL.html> this see...
# fritz2
n
https://docs.fritz2.dev/StylingDSL.html this seems to be not allowed in kotlin syntax? 2 trailing lambda blocks seems to not be allowed
b
You're right, that's why you need to add first lambda into brackets
({})
While we're on the topic, I think styling DSL would be much more readable with some minor adjustments Consider this:
Copy code
fun RenderContext.headerImage(srcUrl: String, alternativeText: String) {
    (::img.styled {
        boxShadow { flat }
        radius { large }
        width(sm = { small }, md = { smaller })
    }) {
        src(srcUrl)
        alt(alternativeText)
    }
}
VS reimagined:
Copy code
fun RenderContext.headerImage(srcUrl: String, alternativeText: String) {
    img.styled({
        boxShadow { flat }
        radius { large }
        width(sm = { small }, md = { smaller })
    }) {
        src(srcUrl)
        alt(alternativeText)
    }
}
or even forget inline styles and just have optional style arguments in existing DSLs:
Copy code
fun RenderContext.headerImage(srcUrl: String, alternativeText: String) {
    img(style = {
        boxShadow { flat }
        radius { large }
        width(sm = { small }, md = { smaller })
    }) {
        src(srcUrl)
        alt(alternativeText)
    }
}

// OR with builder to allow reusable styles as well
fun RenderContext.headerImage(srcUrl: String, alternativeText: String) {
    img(style = styleOf({
        boxShadow { flat }
        radius { large }
        width(sm = { small }, md = { smaller })
    })) {
        src(srcUrl)
        alt(alternativeText)
    }
}
j
@Big Chungus Can you give us an issue on github for it? Than we can discuss there a possible rework of our styling API 😉 https://github.com/jwstegemann/fritz2/issues Thanks!
b
Sure, will do first thing tomorrow