question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Qute: prefix loop metadata

See original GitHub issue

Description

https://quarkus.io/guides/qute-reference#loop_section says that we get iterator metadata index, hasNext, odd and even, but it does not show any example of how to access it, leading me to believe it would be a property of the iterated variable such as it.index. I now realise it showed this example:

{#each items}
  {count}. {it.name} 
{/each}

Which introduces the count metadata, I guess, but because it’s not properly introduced I assumed it was a random toplevel.

The docs should be more clear as to which metadata properties are available, and also this is terrible wrt scoping, because it will automatically override any explicitely declared binding named count or index by surprise.

I do agree it’d be weird to tack these metadata properties to the iterated variable.

In other templates, I’ve seen the iterated variable name being used as a prefix, though, such as it_count or myVar_hasNext which greatly limits binding clashes.

Could we get such prefixed properties instead?

Implementation ideas

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
Ladicekcommented, Oct 12, 2021

Choosing where to stop with adding syntax sugar is certainly one of the more artistic parts of language design 😃

1reaction
gsmetcommented, Oct 12, 2021

Please make sure we have a very actionable error message so that people know how to fix it. I’m pretty sure it’s often used, given how often you have to special case the first or last iteration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Qute Reference Guide - Quarkus
Qute is a templating engine designed specifically to meet the Quarkus needs. ... The iteration metadata prefix is configurable either via EngineBuilder.
Read more >
About Metadata Loop Components - Oracle Help Center
Metadata loop components enable you to assign a value to multiple members using either a function (Metadata) or a start and end value...
Read more >
Index (Qute - Core 2.7.0.CR1 API) - javadoc.io
This prefix is used to access the iteration metadata inside a loop section. iterator() - Method in class io.quarkus.qute.SectionHelperFactory.ParametersInfo ...
Read more >
RFC 2731 Encoding Dublin Core Metadata in HTML - IETF
A DC element is indicated by the prefix "DC", and a non-DC element by another prefix; for example, the prefix "AC" is used...
Read more >
LLVM Language Reference Manual
LLVM requires that values start with a prefix for two reasons: Compilers don't need to worry ... A metadata string is a string...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found