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

enhancement: allow gradient functions through the CSS sanitizer. #587

Closed
ikaio opened this issue Mar 4, 2024 · 1 comment
Closed

enhancement: allow gradient functions through the CSS sanitizer. #587

ikaio opened this issue Mar 4, 2024 · 1 comment

Comments

@ikaio
Copy link

ikaio commented Mar 4, 2024

Hey, Templ Community. I needed to use a gradient background with a custom color provided by the user, but it wasn't working, so I looked at the code and saw that background-image only allows the url function, and background falls under regular sanitization blocking any function at all.
image
image
Also, I know css params was just introduced, but in the future it would be nice if we could use a composite approach, like:
image

@joerdav
Copy link
Collaborator

joerdav commented Mar 5, 2024

#581

We added a new feature for css property escaping, this may solve the issue for you:

css gradient(primary string) {
	background: { templ.SafeCSSProperty(fmt.Sprintf("linear-gradient(to top right, %s, transparent)", primary)) };
}

For future issues, it's much more useful for us to have code snippets rather than screenshots, but none the less thanks for taking the time to report!

@joerdav joerdav closed this as completed Mar 5, 2024
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

No branches or pull requests

2 participants