4.0.3 • Published 1 year ago

ember-truth-helpers v4.0.3

Weekly downloads
120,223
License
MIT
Repository
github
Last release
1 year ago

Ember Truth Helpers CI

HTMLBars template helpers for additional truth logic in if and unless statements.

Compatibility

  • Ember.js v3.28 or above
  • Embroider or ember-auto-import >= 2 (this is v2 addon)

Installation

ember install ember-truth-helpers

Usage

HelperJavaScriptHTMLBarsVariable argument count allowed
eqif (a === b){{if (eq a b)}}No
not-eqif (a !== b){{if (not-eq a b)}}No
notif (!a){{if (not a)}}Yes
andif (a && b){{if (and a b)}}Yes
orif (a || b){{if (or a b)}}    Yes
xorif (a !== b){{if (xor a b)}}No
gtif (a > b){{if (gt a b)}}No
gteif (a >= b){{if (gte a b)}}No
ltif (a < b){{if (lt a b)}}No
lteif (a <= b){{if (lte a b)}}No
is-arrayif (Ember.isArray(a)){{if (is-array a)}}Yes
is-emptyif (Ember.isEmpty(a)){{if (is-empty a)}}No
is-equalif (Ember.isEqual(a, b)){{if (is-equal a b)}}No

API

is-equal

is-equal uses Ember.isEqual helper to evaluate equality of two values. eq should be sufficient for most applications. is-equal is necessary when trying to compare a complex object to a primitive value.

Other Helpers

Usage with Glint

ember-truth-helpers is a glint enabled addon. Add this to your types/global.d.ts file:

import '@glint/environment-ember-loose';

import type EmberTruthRegistry from 'ember-truth-helpers/template-registry';

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry extends EmberTruthRegistry, /* other addon registries */ {
    // local entries
  }
}

For the entire guide, please refer to Using Addons section on the glint handbook.

Types are made available through package.json exports field. In order for TS to recognize this (beginning from TS 4.7), you must set moduleResolution to node16 or nodenext.

Usage in Single File Components

For usage in gts or gjs files, all helpers are exported from the index:

import { or } from 'ember-truth-helpers';

<template>
  {{#if (or @admin @user)}}
    Admin Controls are going here
  {{/if}}
</template>

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

ember-basic-dropdown-f2ember-power-select-f2ember-ux-controlsember-more-menu@opendata.fit/ember-simple-tabsember-scaffoldingember-jane-maps@opendatafit/ember-simple-tabs@infinitebrahmanuniverse/nolb-ember-tember-elements@everything-registry/sub-chunk-1579shamgar-audit-trailjobs-widgetjusta-tableguidemaker-ember-locale-templateguidemaker-ember-templateilios-commonlabs-ember-searchlacssonavi-corenavi-dashboardspaper-origamiocularium-frontend-corenypr-design-systemprember-metanmbl-prostack-componentspharbers-standard-base-addonpharbers-tm-cardsnavi-reportsqpid-ember-baserevv-v3ui-calendarui-buttonui-iconui-tabsui-bootstrapui-selectizeui-list@appuniversum/ember-appuniversum@andreo141/ember-metis@bagaar/velvet-thunder@cardstack/tools@cardstack/ui-components@cardstack/rendering@cardstack/boxel@cenchat/core@choiceform/ember-cform-ui@choiceform/ember-choice-ui@choiceform/os-client-ui@choiceform/ui-button@choiceform/ui-list@centerforopenscience/ember-osf@cloudcreativity/ember-quill@1024pix/pix-ui@bennerinformatics/ember-fw@bennerinformatics/ember-fw-issue@bennerinformatics/ember-fw-tableyebo-ember-storefrontzy-ember-power-selectvinli-chartsupfluence-oss-components@dtox/ember-utils@hashicorp/design-system-components@icarusworks/ember-power-select@fixparts/ui@fleetbase/ember-ui@ember-eui/validated-form@ember-eui/core@ember-eui/flatpickr@ember-eui/pikaday@ember-eui/changeset-form@gavant/ember-floating-labels@gavant/ember-page-layout@freshworks/badge@freshworks/banner@freshworks/button@freshworks/datepicker@freshworks/inline-banner@freshworks/modal@freshworks/pagination@freshworks/table@freshworks/tabs@freshworks/toast-message@lblod/ember-rdfa-editor-aanwezigen-plugin@lblod/ember-rdfa-editor-agenda-plugin@lblod/ember-rdfa-editor-bijzonder-comite-aanstelling-plugin@lblod/ember-submission-form-fields@love-open-source/ember-slider@movable/fluid@myorders/ember-ui@nacho-ui/button@nacho-ui/table@eflexsystems/ember-cli-wizard@jubileesoft/ember-jubileesoft-ui@rancher/ember-shared@plonquo/ember-material-components@s-l-i/sli-plots@projectcaluma/ember-form@projectcaluma/ember-workflow@opendatafit/ember-basic-tabs
4.0.1

1 year ago

4.0.0

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

4.0.0-beta.0

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

4 years ago

2.1.0

6 years ago

2.0.0

7 years ago

1.3.0

8 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago