shama / yo-yoify

Transform choo, yo-yo or bel template strings into pure and fast document calls
111 stars 17 forks source link

Not recursively transforming ??? #18

Closed MattMcFarland closed 8 years ago

MattMcFarland commented 8 years ago

The question marks there as this appears to be the issue as the source is not changing from using html

screenshot from 2016-07-25 22 57 05

screenshot from 2016-07-25 23 21 31

The origin of the error occurs here: https://github.com/trainyard/generator-choo/issues/6

We were able to fix our build script by removing yo-yoify: https://github.com/trainyard/generator-choo/commit/4469ee91ee808f4856d8a407839bbb3c34d0d352

shama commented 8 years ago

I think this line: https://github.com/trainyard/generator-choo/blob/master/app/templates/src/components/todo-list.js#L8 is the issue.

It is expecting the template string to be HTML but instead it is just an expression so it leaves it alone.

If each todo is already an HTML element, you don't need to wrap it in a tagged template string. Just do this instead:

module.exports = (todos = [], send) => html`
  <ul>
    ${
      todos.map(item => todo(item, () => send('todoDemo:toggle', {id: item.id})))
    }
  </ul>
`
MattMcFarland commented 8 years ago

Wow that totally fixed it.. Thanks!!!

Man I almost think it might be nice to add a eslint plugin or something.. Or maybe have yo-yoify throw an error if it sees that?

shama commented 8 years ago

Yep! I agree it would be cool if yo-yoify threw an error on things like that. I'll look into it.