Comments (3)
Reading through the code, it was expecting quoted URLs for CSS url
props. I've put forward a PR which adds support for single quoted, double quoted, and unquoted strings.
from templ.
@koddr - please refer to this example. I think the docs need to be updated.
package main
import "os"
templ page() {
<!DOCTYPE html>
<html>
<head>
<title>Background image</title>
</head>
<body>
<div>
@profile("image1.png")
</div>
<div>
@profile("image2.png")
</div>
</body>
</html>
}
templ profile(image string) {
<div class={ profileCSS(image) }>
Profile
</div>
}
func bgImage(trustedURL string) templ.SafeCSSProperty {
return templ.SafeCSSProperty("url(" + trustedURL + ")")
}
css profileCSS(image string) {
background-image: { bgImage(image) };
}
func main() {
page().Render(context.Background(), os.Stdout)
}
Also, thinking about the next version of templ, supporting this:
css profileCSSNext(image string) {
background-image: { templ.URL(image) };
}
from templ.
@a-h thanks for the release, but bug is still here :(
Input code:
css bgImage(u string) {
background-image: url({ u });
}
Output (generated) code:
<style type="text/css">
.bgImage_0918{
background-image:url({ u });
}
</style>
Config:
- templ:
v0.2.639
- templ-vscode:
v0.0.22
from templ.
Related Issues (20)
- Help with intercepting middleware, and writing responses HOT 4
- Proposal: Change URL's signature to match [S]Printf HOT 3
- Script application/ld+json HOT 4
- lsp error when ı reload or open templ file HOT 8
- [v0.2.717] error: column is beyond end of line HOT 28
- Connection to server got closed. Server will not be restarted. (source: templ-vscode) HOT 4
- proposal: Cache-bust Static Assets HOT 4
- I am getting error with templ-vscode extension HOT 7
- Error Starting VCS Extension HOT 3
- parser: Calling methods on a new line
- Explanation HOT 1
- Server initialization failed. HOT 5
- Investigate issue raised in vscode-go HOT 1
- LSP: Autocomplete seems broken HOT 2
- VS Code: Request textDocument/codeAction failed. HOT 1
- docs: TailwindCSS setup autocomplete no longer work HOT 8
- Vscode plugin crash HOT 4
- [question] go 1.22 iterators / rangefunc HOT 3
- Release `v0.2.731` breaks Mason.nvim integration HOT 5
- using context with implicit vs explicit import HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templ.