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

List items #27

Closed
rbiggs opened this issue Mar 26, 2017 · 6 comments
Closed

List items #27

rbiggs opened this issue Mar 26, 2017 · 6 comments

Comments

@rbiggs
Copy link

rbiggs commented Mar 26, 2017

Nice framework. I've used straight template literals a lot. I love them. I've also used Yo-yo/Choo, Hyperx with Virtual Dom and Hyperapp. I'm not quite sure how to handle rendering repeating items from an array. I tried creating an example of composable parts, but can't seem to get the list items to render. They come back as strings, not what I was expecting. With normal template literals that would work. What am I doing wrong?

const render = hyperHTML.bind(document.body)
const wire = hyperHTML.wire()

const fruits = ['Apples', 'Oranges', 'Bananas']

const header = render => render`
  <nav>
    <h1>The Title</h1>
  </nav>`;

const footer = render => render`
  <footer>
    <h3>The footer</h13>
  </footer>`

const main = render => render`
  <section>
    <h2>Fruits</h2>
    <ul>
      ${fruits.map(fruit => `<li>${fruit}</li>`).join('')}
    </ul>
  </section>`

const update = render => render`${[header(wire), main(wire), footer(wire)]}`
update(render)
@WebReflection
Copy link
Owner

You're putting spaces around. There are only 3 rules to remember, please read them.

@rbiggs
Copy link
Author

rbiggs commented Mar 26, 2017

Ah, you mean on the ul. 🤦‍♂️

@WebReflection
Copy link
Owner

Yes, and if you want safe text inside

  • put at least a space around. HTML and wires are opt in and the best compromise is to have no spaces around. It'd be impossible to have this behavior swapped but it worked for all simple-to-complex examples and demos.

  • @WebReflection
    Copy link
    Owner

    Put a space around < li >

    @WebReflection
    Copy link
    Owner

    Sorry I can't answer through my phone any better at this time

    @rbiggs
    Copy link
    Author

    rbiggs commented Mar 26, 2017

    No probs. Thanx a lot. Appreciate the quick response ;-)

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

    No branches or pull requests

    2 participants