How to receive an optional parameter in a component? #844
Answered
by
a-h
henriqueleite42
asked this question in
Q&A
-
I have the following component: templ DefaultLayout(title string, head templ.Component) {
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>{ title }</title>
@head
</head>
<body>
{ children... }
</body>
</html>
} And I want |
Beta Was this translation helpful? Give feedback.
Answered by
a-h
Jul 12, 2024
Replies: 1 comment 1 reply
-
Yes, there's a couple of ways.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
henriqueleite42
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, there's a couple of ways.
templ
just creates a Go function, so it's the same as Go.templ.Component
is an interface, so it can be nil.Use a struct to take params