unexpected loop behavior when rendering templates.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- frontend
Research direction
Start by reproducing the provided template with @repeat and @set, then trace the template-rendering path that handles loop variables and substitutions. Compare it with the working direct-DOM loop example; done means the template example renders the expected background and foreground values without the workaround.
Written by the indexing model from the issue text.
Description
Hello and thank you so much for this wonderful language!
Hyperscript completely solves all my tasks on the front end, with the exception of a small problem: SET command in the template's loop doesn't work.
The code from the example of using templates does not work:
<template id="color-template">
<ul>
@repeat in colors
@set bg to it -- this command return lenght of it, but not it as Object
@set fg to getContrastingColor(it) -- the same problem
<li style="background: ${bg}; color: ${unescaped fg}">${bg}</li>
@end
</ul>
</template>
And this code works:
<template id="color-template">
@repeat in colors
<li style="background: ${it}; color: ${getContrastingColor(it)}">${it}</li>
@end
</template>
I found a workaround: using loops directly in DOM elements (when more complex logic is required). I'm not very versed in JavaScript (that's why I chose Hyperscript) to send the pull request, but I hope that this bug causes inconvenience to someone else and it can be fixed.
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bigskysoftware/_hyperscript
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bigskysoftware/_hyperscript#688 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bigskysoftware/_hyperscript#678 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bigskysoftware/_hyperscript#676 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
bigskysoftware/_hyperscript#695 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
bigskysoftware/_hyperscript#687 ·
All issues in bigskysoftware/_hyperscript
Similar issues
-
external-issue to-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
LearningCircuit/local-deep-research#7067 ·
Maintainers usually reply within 1 day
-
automated issue report
Difficulty 1/5 Under an hour Newbie friendliness 65/100
lirantal/discoprint#32 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day