Code Monkey home page Code Monkey logo

Comments (3)

a-h avatar a-h commented on September 23, 2024 1

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.

a-h avatar a-h commented on September 23, 2024 1

@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.

koddr avatar koddr commented on September 23, 2024

@a-h thanks for the release, but bug is still here :(

screen

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.