Skip to content

Inline if conditions #783

Closed Answered by joerdav
k0mpreni asked this question in Q&A
Jun 6, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

At the moment I think an if statement is your best bet.

There is another option though..

If you don't care about the value of the attribute you can use boolean attributes:

templ check(i int) {
	<input
		type="radio"
		name="my-accordion-2"
		checked?={ i == 0 }
	/>
}

Which results in:

<input type="radio" name="my-accordion-2" checked>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@k0mpreni
Comment options

Answer selected by k0mpreni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants