Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass hostname to all html templates #133

Merged

Conversation

armandocerna
Copy link
Contributor

We would like our html templates to reflect the hostname override we are passing to golink, these changes pass the hostname to all HTML templates

@bradfitz bradfitz requested a review from willnorris July 8, 2024 21:40
@willnorris
Copy link
Member

willnorris commented Jul 9, 2024

rather than passing the hostname in as a variable, how about registering a function that can be used in all of the templates? It feels a tiny bit wrong to use "go" as the func name, since it's already a keyword, but it works pretty well since it's not actually a registered template func. So something like:

	tmplFuncs := template.FuncMap{
		"go": func() string {
			return *hostname
		},
	}

which is registered on all of the templates, and then inside the template files themselves, we can use {{go}}, which is still quite readable. I've got the start of this working if you're okay with me pushing it to your branch?

@armandocerna
Copy link
Contributor Author

Much cleaner, I like it! Totally ok with you pushing to my branch.

@armandocerna
Copy link
Contributor Author

I saw you were curious, very simple change we use so for the hostname we have an internal cli utility named the same

@willnorris willnorris force-pushed the fix/template-hostname-overrides branch from 994dbcc to 5d45925 Compare July 9, 2024 05:09
@willnorris willnorris merged commit a83ef33 into tailscale:main Jul 9, 2024
3 of 4 checks passed
willnorris added a commit that referenced this pull request Jul 9, 2024
This allows us to include the custom hostname in the sample form.

Updates #133

Signed-off-by: Will Norris <[email protected]>
willnorris added a commit that referenced this pull request Jul 9, 2024
This allows us to include the custom hostname in the sample form.

Updates #133

Signed-off-by: Will Norris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants