Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-truth-helpers

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-truth-helpers

Ember Truth Helpers

  • 4.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
114K
increased by33.72%
Maintainers
4
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 11 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc