brianmhunt / knockout-fast-foreach

Foreach. Faster. For Knockout.
MIT License
58 stars 18 forks source link

Maybe templating shouldn't be supported #45

Open cervengoc opened 7 years ago

cervengoc commented 7 years ago

Because fastForEach doesn't use the native template binding internally for rendering templates, it can lead to several issues like

I suggest removing the templating options and syntaxes, and recommending using an inner template binding like this.

<div data-bind='fastForEach: items">
  <!-- ko template: 'my-name' -->
  <!-- /ko -->
</div>

Or the same with non-containerless version if one can allow it.

This is be a breaking change of course, and should be added only into the final version IMO.

brianmhunt commented 7 years ago

Yeah, I think for TKO-alpha/beta this would be wise.

cervengoc commented 7 years ago

I don't know the native template's foreach option's implementation very well, but you should take that into account too, because that may interfere with fastForEach as well.

jlaustill commented 7 years ago

I actually just got around to testing this today, and this is literally the only way I use foreach. My entire site is a bunch of these

<!-- ko with: blog -->
<div data-bind="template: { name: 'pagination' }"></div>
<div data-bind="template: { name: 'post', foreach: posts, as: 'post' }"></div>
<div data-bind="template: { name: 'pagination' }"></div>
<!-- /ko -->

Except the ones that are components of course. So as of today, this doesn't seem to work for me. I would prefer this syntax stick around personally, I find it graceful, useful, and extremely easy to come back to after months of not seeing the code.

If I had to switch to the template inside a foreach syntax, it wouldn't be the end of the world, but I'd prefer not to for sure.

cervengoc commented 7 years ago

@jlaustill I ment the fastForEach binding syntax which let's you pass a template name. I didn't mean to touch the template syntax with the foreach options, that's a different story.

However, if fastForEach gets into the knockout core and possibly replaces the original foreach, the template syntax you mentioned should be something to think about. But I think we could at least call fastForEach and template respectively under the hood, so that the syntax would remain the same.