GithubHelp home page GithubHelp logo

Comments (8)

a-h avatar a-h commented on August 28, 2024

Oh, that's not right. I was surprised that this isn't covered in the test suites, but all of the tests use the empty value (_). I'll sort that too.

I suspect this issue was introduced when go expressions started being formatted, and the parser errors propagated.

I won't be able to fix it until next weekend though.

In the meantime, the classic 3 part for loop will work (for i := 0; i < len(z); i++), albeit it's less ergonomic.

I think the fix will likely be to ignore unused variable errors during formatting operations, and leave any unused variable issues to be discovered in the generated output, but I'll have to look into it more.

from templ.

adonespitogo avatar adonespitogo commented on August 28, 2024

Thank you, great project by the way. I'll use the classic for loop for now.

from templ.

joerdav avatar joerdav commented on August 28, 2024

Hi @adonespitogo I'm taking a look at this. What version of templ are you using please?

from templ.

joerdav avatar joerdav commented on August 28, 2024

Second, what command are you running to see this error? Or is it in the editor?

from templ.

adonespitogo avatar adonespitogo commented on August 28, 2024

Hi @joerdav

Hi @adonespitogo I'm taking a look at this. What version of templ are you using please?

v0.2.707

Second, what command are you running to see this error? Or is it in the editor?

cd templates && templ generate

from templ.

joerdav avatar joerdav commented on August 28, 2024

I'm struggling to reproduce this, your original code is not valid templ so I couldn't just copy it into a file. I changed it into a valid templ file and couldn't get it to error:

package adon

templ t() {
	for i, nav := range navs {
		if nav.Active {
			<a id={ navId(i) } href="{ nav.Url }">{ nav.Text }</a>
		}
	}
}

func navId(i int) {
	return fmt.Sprintf("navid-%d", i)
}

Please can you consider creating a minimal reproducible example, either as a github repo or a single templ file that I can copy?

from templ.

adonespitogo avatar adonespitogo commented on August 28, 2024

Hi @joerdav

I can no longer reproduce this issue. Perhaps it was a mistake on my part, a lot has changed in my code since then. Sorry for bringing this up. Feel free to close this issue.

from templ.

joerdav avatar joerdav commented on August 28, 2024

No problem, thanks for coming back to update!

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.