-
When I have a layout templ DefaultLayout() {
<html langCode={ ctx.Value("langCode").(string) }
{children...}
</html>
} I would want to be able to have the langCode set for example. templ SignInPage() {
@layout.DefaultLayout() {
<p>SignInPage</p>
}
} Is there an easy way to access the context in the layout without passing it around via parameter? What is the recommended approach here? |
Beta Was this translation helpful? Give feedback.
Answered by
pczern
Nov 2, 2024
Replies: 1 comment
-
Turns out using echo's ctx := context.WithValue(c.Request().Context(), "title", siteTitle)
c.SetRequest(c.Request().WithContext(ctx)) that way also no parameters are needed in DefaultLayout |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pczern
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns out using echo's
c.Set("langCode", "en")
is another context than set bythat way also no parameters are needed in DefaultLayout