Skip to content

RFC#562 - {{and}}, {{or}}, {{not}} as keywords#21337

Open
NullVoxPopuli wants to merge 4 commits intoemberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/and-or-not-as-keyword
Open

RFC#562 - {{and}}, {{or}}, {{not}} as keywords#21337
NullVoxPopuli wants to merge 4 commits intoemberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/and-or-not-as-keyword

Conversation

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

@NullVoxPopuli NullVoxPopuli commented Apr 22, 2026

Implement and/or/not.

RFC Link: https://rfcs.emberjs.com/id/0562-add-logical-operators/

We do need to also PR an update to the RFC to say that these are only available in strict mode

We decided that new helpers would only be available in strict mode, because we don't want to change loose mode, for safety reasons

Add boolean logic helpers and register them as built-in keywords
so they no longer need to be imported in strict-mode (gjs/gts) templates.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
bertdeblock
bertdeblock previously approved these changes Apr 23, 2026

/**
* The `{{and}}` helper evaluates arguments left to right, returning the first
* falsy value (using Handlebars truthiness) or the right-most value if all
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel liks since this will be going in the API docs we need to have some sort of cross-link to some document that explains what Handlebars truthiness actually means 😂 I can see in the implementation that we're using the toBool() function, does that have public API docs?

Copy link
Copy Markdown
Member

@mansona mansona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks fine to me (with my limited experience reviewing lanugage-level PRs like this) but I did notice that we are exposing sometihng in the API docs that is under-explained 🤔 I have approved this to not block the implementation but I would like to see the API docs improved before this makes its way to beta (i.e. you can do a follow up PR if you like but I would like you to commit to it 👍 )

@NullVoxPopuli NullVoxPopuli marked this pull request as draft April 24, 2026 14:18
@NullVoxPopuli
Copy link
Copy Markdown
Contributor Author

Converted back to draft because:

  • I want to explore what making argument evaluation lazy would look like (I know how, I just don't know how much work it is yet)
  • I want to ask the community if we should change the truthiness semantics to be more js-like, since the original RFC was for loosemode without keyword shadowing, and now we are only going to support this in strict mode which has keyword shadowing

@void-mAlex
Copy link
Copy Markdown

the one thing I would hate from going to js thruthy semantics is empty arrays being truthy

@NullVoxPopuli
Copy link
Copy Markdown
Contributor Author

NullVoxPopuli commented Apr 24, 2026

that's how ember-truth-helpers currently works, but I think since we have keyword shadowing, we/I should RFC an update that amends this RFC for and/or/not to say JS semantics for truthiness... because... [] being falsey is bonkers haha

hopefully I can get that submitted before the RFC meeting

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

Successfully merging this pull request may close these issues.

4 participants