Skip to content

Commit

Permalink
add Titlef
Browse files Browse the repository at this point in the history
  • Loading branch information
maxence-charriere committed Jul 10, 2023
1 parent faed131 commit 5804491
Show file tree
Hide file tree
Showing 3 changed files with 1,008 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/app/gen/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,11 @@ var attrs = map[string]attr{
Type: "string",
Doc: "specifies extra information about an element.",
},
"titlef": {
Name: "Titlef",
Type: "fmt",
Doc: "specifies extra information about an element with the given format and values.",
},
"type": {
Name: "Type",
Type: "string",
Expand Down Expand Up @@ -1679,6 +1684,7 @@ func withGlobalAttrs(attrs ...attr) []attr {
"styles",
"tabindex",
"title",
"titlef",
"attribute",
)...)

Expand Down Expand Up @@ -2463,6 +2469,15 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
}`)
}

case "fmt":
fmt.Fprintf(w, `%s(format string, v ...any) HTML%s`, a.Name, t.Name)
if !isInterface {
fmt.Fprintf(w, `{
e.setAttr("%s", fmt.Sprintf(format, v...))
return e
}`, attrName)
}

default:
fmt.Fprintf(w, `%s(v %s) HTML%s`, a.Name, a.Type, t.Name)
if !isInterface {
Expand Down Expand Up @@ -2555,6 +2570,9 @@ import (
case "xmlns":
fmt.Fprintln(f, `"http://www.w3.org/2000/svg")`)

case "fmt":
fmt.Fprintln(f, `"hello %v", 42)`)

default:
fmt.Fprintln(f, `42)`)
}
Expand Down
Loading

0 comments on commit 5804491

Please sign in to comment.