4.0.3 • Published 7 months ago

ember-truth-helpers v4.0.3

Weekly downloads
120,223
License
MIT
Repository
github
Last release
7 months 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-1579@hashicorp/design-system-components@freshworks/inline-banner@freshworks/modal@freshworks/pagination@freshworks/badge@freshworks/banner@freshworks/button@freshworks/datepicker@freshworks/table@freshworks/tabs@freshworks/toast-message@icarusworks/ember-power-select@eflexsystems/ember-cli-wizard@fleetbase/ember-ui@fixparts/ui@gavant/ember-floating-labels@gavant/ember-page-layout@dtox/ember-utils@ember-eui/validated-form@ember-eui/changeset-form@ember-eui/core@ember-eui/flatpickr@ember-eui/pikadaygavant-ember-button-basicgavant-fl-input@love-open-source/ember-slider@precision-nutrition/date-picker@plonquo/ember-material-components@projectcaluma/ember-form@projectcaluma/ember-workflow@s-l-i/sli-plotsvinli-charts@jubileesoft/ember-jubileesoft-ui@movable/fluidguidemaker-ember-locale-templateguidemaker-ember-templatelabs-ember-searchui-tabsui-listui-iconui-selectizeilios-commonui-bootstrapui-buttonui-calendarjobs-widget@rancher/ember-sharedjusta-tableupfluence-oss-components@nsf-open/ember-ui-foundation@nycplanning/ember@lblod/ember-rdfa-editor@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@nacho-ui/button@nacho-ui/table@opendatafit/ember-basic-tabs@vinli/vinli-uinavi-corenavi-dashboards@wildland-labs/ember-bootstrap-controls@xdam/ember-partialsnavi-reportslacsso@themarshalsgroup/ember-ui@smile-io/ember-polaris@smile-io/ember-smile-polariszy-ember-power-select@twyr/ember-abstract-dropdown@twyr/ember-mdc-web@trusted-american/design-systemnmbl-prostack-components@1024pix/pix-uicardstack-cmscardstack-editorpaper-origami@bennerinformatics/ember-fw@bennerinformatics/ember-fw-issue@bennerinformatics/ember-fw-tableciena-devops-testbed@cardstack/tools@cardstack/ui-components@cardstack/rendering@cardstack/boxel@cenchat/core@centerforopenscience/ember-osf@choiceform/ui-button
4.0.1

8 months ago

4.0.0

8 months ago

4.0.3

7 months ago

4.0.2

7 months ago

4.0.0-beta.0

8 months 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

7 years ago

1.2.0

8 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago