Skip to content

#html macro eats away trailing closure when interpolating a function call #5

Closed
@andrebraga

Description

@andrebraga

Given

func strBldArg(_ a: String) -> String {
  a
}
func strBldNamedArg(a: String) -> String {
  a
}
func strBld(_ body: () -> String) -> String {
  body()
}

We have the following expansions:

let a: String = #html(div(strBldArg("a")))

"<div>\(strBldArg("a"))</div>" (good)

let b: String = #html(div(strBldNamedArg(a: "b")))

"<div>\(strBldNamedArg(a: "b"))</div>" (also good)

let c: String = #html(div(strBld{ "c" }))

"<div>\(strBld())</div>" (Oops! The closure is gone!)

let d: String = #html(div(strBld({ "d" })))

"<div>\(strBld({ "d" }))</div>" (Good 😃)

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions