From 06fffd9f05572401db90a981cda53910180f11f4 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 03:21:04 +0000 Subject: [PATCH] Document how the get helper treats keys containing a period The key passed to `{{get}}` is a path, so `{{get obj "some.key"}}` reads `obj.some.key`. Document that, and show a plain function as the way to read a property whose name contains a period. Also fix the sentence after the dynamic key example, which referred to an example that no longer exists. Closes #21411 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013JirFwqPVyTTFj5zPbonSh --- packages/@ember/helper/index.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/@ember/helper/index.ts b/packages/@ember/helper/index.ts index 945dcd1c469..c50fc30e417 100644 --- a/packages/@ember/helper/index.ts +++ b/packages/@ember/helper/index.ts @@ -477,8 +477,35 @@ export interface ConcatHelper extends Opaque<'helper:concat'> {} * * ``` * - * This will display the result of `@foo.item1` when `index` is `1`, and - * `this.foo.item2` when `index` is `2`, etc. + * This will display the result of `@address.street` when `@field` is + * `"street"`, and `@address.city` when `@field` is `"city"`, etc. + * + * The key is treated as a path, so a key containing a period is split on each + * period and looked up one segment at a time: + * + * ```gjs + * import { get } from '@ember/helper'; + * + * const person = { address: { city: 'Portland' } }; + * + * + * ``` + * + * This also means that `{{get}}` cannot read a property whose name itself + * contains a period. `{{get obj "some.key"}}` looks up `obj.some.key`, not + * `obj["some.key"]`, and returns `undefined` when `obj.some` does not exist. + * To read such a key, use a plain function instead: + * + * ```gjs + * const obj = { 'some.key': 'some value' }; + * const lookup = (object, key) => object[key]; + * + * + * ``` * * @method get * @for @ember/helper