Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected loop behavior when rendering templates. #590

Open
serkopa opened this issue Nov 13, 2024 · 0 comments
Open

unexpected loop behavior when rendering templates. #590

serkopa opened this issue Nov 13, 2024 · 0 comments

Comments

@serkopa
Copy link

serkopa commented Nov 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant