Giter VIP home page Giter VIP logo

Comments (3)

sukima avatar sukima commented on July 18, 2024

I much prefer the behavior it is using now. It aligns with how Ember templates treat empty arrays. Changing it will make it behave different then how Ember handles empty arrays.

{{#each (array) as |item|}}
  This never is handled
{{else}}
  This is handled as the items are empty
{{/each}}

{{#if (array)}}
  Never gets called
{{else}}
  Treated as falsey 'cause the array is empty
{{/if}}

{{if (array) "Not shown" "shown because falsey"}}

from ember-truth-helpers.

boris-petrov avatar boris-petrov commented on July 18, 2024

Well, I guess that's a matter of taste. I personally would prefer to have the same behavior in JS and in HBS for similar things - so if ([]) ... to behave the same as {{if (array) ...}}. each is a bit different as it doesn't have a direct equivalent in JS (I mean the else part of course) - so I agree that the current behavior is OK. But for the if examples I think that's confusing to people. Besides, you could just write {{if someArray.length ...}} and that would work the way you want.

from ember-truth-helpers.

boris-petrov avatar boris-petrov commented on July 18, 2024

So after a nice discussion I'll close the issue as ember-truth-helpers does the correct thing according to the RFC (even though the RFC says that ember-truth-helpers does something else - the RFC is wrong in this case).

from ember-truth-helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.