
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
Computed Property Macros for Ember
Version 2.0+ will only work with Ember 2.0+ Version 3.0+ is only tested in the last 2 LTS.
Just run ember install ember-cpm
Just import individual macros from ember-cpm/macros/* or all macros from ember-cpm.
// Import only one macros
import ifNull from "ember-cpm/macros/if-null";
// or alternatively import all the namespace
import EmberCPM from "ember-cpm";
To generate a new computed property macros with ember-cli
ember g macro <dasherized-macro-name>. This will generate a few files
./addon/macros/dasherized-macro-name.js (the macro)./addon/tests/dummy/unit/macro/dasherized-macro-name-test.js (a test)*./addon/ember-cpm.js// import the macro
import camelizedMacroName from './macros/dasherized-macro-name.js'
...
var Macros = {
...
// allows use via EmberCPM.Macros.camelizedMacroName
camelizedMacroName: camelizedMacroName,
...
};
ember d macro <dasherized-macro-name> will do the reverse of these changes
among -- returns true if the original value is among the given literals
(testing using ===)encodeURIComponent -- calls encodeURIComponent on the original valueencodeURI -- calls encodeURI on the original valuefirstPresent -- returns the first property with a value, as determined by Ember.isPresentfmt -- pass the original values into a format-stringhtmlEscape -- escapes the original value with
Handlebars.Utils.escapeExpression and wraps the result in a
Handlebars.SafeString (since it's now safe)ifNull -- fall back on a default valuepromise -- wraps the original value in an already-resolved promisesafeString -- wraps the original value in a Handlebars.SafeStringjoin -- joins the supplied values together with a provided sepatatorquotient -- divides one numeric property or literal by anotherdifference -- subtracts one numeric property or literal from anotherproduct -- multiplies numeric properties and literals togethersum -- sums numeric properties and literals togetherconditional -- returns values based on a boolean property (good replacement for ternary operator)computedPromise -- Updates computed property when supplied callback (which must return a promise) is resolvedUnlike Ember's computed property macros, the macros in this addon are composable. That means you define macros inside other macros without defining them in a separate key.
import Ember from 'ember';
import EmberCPM from 'ember-cpm';
const { Macros: { sum, difference, product } } = EmberCPM;
export default Ember.Component.extend({
num1: 45,
num2: 3.5,
num3: 13.4,
num4: -2,
total: sum(
sum('num1', 'num2', 'num3'),
difference('num3', 'num2'),
product(difference('num2', 'num1'), 'num4')
)
});
FAQs
Computed Propery Macros for Ember.js
The npm package ember-cpm receives a total of 52 weekly downloads. As such, ember-cpm popularity was classified as not popular.
We found that ember-cpm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

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.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.