@@ -9196,6 +9196,10 @@ This module contains the API for templating. For more detailed instructions, rea
91969196 * [~featureBits(options)](#module_Templating API_ Attribute helpers..featureBits) ⇒
91979197 * [~attributeDefault()](#module_Templating API_ Attribute helpers..attributeDefault) ⇒
91989198 * [~as_underlying_atomic_identifier_for_attribute_id(attributeId)](#module_Templating API_ Attribute helpers..as_underlying_atomic_identifier_for_attribute_id)
9199+ * [~selectFeatureBitmapForCluster(db, packageIds, clusterId)](#module_Templating API_ Attribute helpers..selectFeatureBitmapForCluster) ⇒ <code>Promise.<(object\|null)></code>
9200+ * [~if_cluster_has_feature_bitmap(options)](#module_Templating API_ Attribute helpers..if_cluster_has_feature_bitmap) ⇒ <code>Promise.<string></code>
9201+ * [~if_feature_bit_enabled(options)](#module_Templating API_ Attribute helpers..if_feature_bit_enabled) ⇒ <code>string</code>
9202+ * [~cluster_feature_items(options)](#module_Templating API_ Attribute helpers..cluster_feature_items) ⇒ <code>Promise.<string></code>
91999203
92009204<a name="module_Templating API_ Attribute helpers..count_mandatory_matter_attributes"></a>
92019205
@@ -9236,6 +9240,139 @@ atomic table.
92369240| --- | --- |
92379241| attributeId | <code>\*</code> |
92389242
9243+ <a name="module_Templating API_ Attribute helpers..selectFeatureBitmapForCluster"></a>
9244+
9245+ ### Templating API: Attribute helpers~selectFeatureBitmapForCluster(db, packageIds, clusterId) ⇒ <code>Promise.<(object\|null)></code>
9246+ Returns the cluster-scoped 'Feature' bitmap, or null when the cluster does not
9247+ define one. Uses selectBitmapByNameAndClusterId for a targeted lookup, then
9248+ confirms the bitmap is associated with clusterId (the DB helper may return a
9249+ package-wide singleton when only one bitmap with that name exists).
9250+
9251+ **Kind**: inner method of [<code>Templating API: Attribute helpers</code>](#module_Templating API_ Attribute helpers)
9252+
9253+ | Param | Type |
9254+ | --- | --- |
9255+ | db | <code>\*</code> |
9256+ | packageIds | <code>Array.<number></code> |
9257+ | clusterId | <code>number</code> |
9258+
9259+ <a name="module_Templating API_ Attribute helpers..if_cluster_has_feature_bitmap"></a>
9260+
9261+ ### Templating API: Attribute helpers~if\_cluster\_has\_feature\_bitmap(options) ⇒ <code>Promise.<string></code>
9262+ Block helper that renders its body when the cluster in the current context
9263+ defines a bitmap named 'Feature', and its inverse ({{else}}) when it does
9264+ not. Intended for choosing between `using FeatureBitmapType = Feature;` and
9265+ `using FeatureBitmapType = Clusters::StaticApplicationConfig::NoFeatureFlagsDefined;`
9266+ in static-cluster-config headers.
9267+
9268+ Must be used inside a context that exposes a cluster `id` field, such as
9269+ `zcl_clusters`, `selectedServerCluster`, or any block helper whose context
9270+ object carries the ZCL cluster database ID as `id`.
9271+
9272+ **Kind**: inner method of [<code>Templating API: Attribute helpers</code>](#module_Templating API_ Attribute helpers)
9273+ **Returns**: <code>Promise.<string></code> - Rendered `fn` block when the cluster has a
9274+ bitmap named 'Feature'; rendered `inverse` block otherwise.
9275+
9276+ | Param | Type | Description |
9277+ | --- | --- | --- |
9278+ | options | <code>\*</code> | Handlebars options object (fn / inverse blocks). |
9279+
9280+ **Example**
9281+ ```js
9282+ // Inside a selectedServerCluster or zcl_clusters block:
9283+ {{#if_cluster_has_feature_bitmap}}
9284+ using FeatureBitmapType = Feature;
9285+ {{else}}
9286+ using FeatureBitmapType = Clusters::StaticApplicationConfig::NoFeatureFlagsDefined;
9287+ {{/if_cluster_has_feature_bitmap}}
9288+ ```
9289+ <a name="module_Templating API_ Attribute helpers..if_feature_bit_enabled"></a>
9290+
9291+ ### Templating API: Attribute helpers~if\_feature\_bit\_enabled(options) ⇒ <code>string</code>
9292+ Block helper that renders its body when the bitwise AND of `featureMapValue`
9293+ and `mask` is non-zero (i.e. the specific feature bit is set), and its
9294+ inverse ({{else}}) when the bit is clear.
9295+
9296+ Both arguments are parsed as integers so decimal strings (e.g. `"3"`) and
9297+ hex strings (e.g. `"0x3"`) are accepted.
9298+
9299+ Combine with `cluster_feature_items` when you want to iterate over feature
9300+ fields and selectively render only those that are enabled:
9301+ {{#cluster_feature_items clusterCode}}
9302+ {{#if_feature_bit_enabled featureMapValue mask}}...{{/if_feature_bit_enabled}}
9303+ {{/cluster_feature_items}}
9304+
9305+ **Kind**: inner method of [<code>Templating API: Attribute helpers</code>](#module_Templating API_ Attribute helpers)
9306+ **Returns**: <code>string</code> - Rendered `fn` block when `(featureMapValue & mask) !== 0`;
9307+ rendered `inverse` block otherwise.
9308+ **Given**: <code>string\|number</code> featureMapValue - The raw FeatureMap attribute default
9309+ value for the current endpoint cluster (e.g. `"3"`).
9310+ **Given**: <code>string\|number</code> mask - The bitmask of the feature field being tested
9311+ (e.g. `1`).
9312+
9313+ | Param | Type | Description |
9314+ | --- | --- | --- |
9315+ | options | <code>\*</code> | Handlebars options object (fn / inverse blocks). |
9316+
9317+ **Example**
9318+ ```js
9319+ // LevelControl, featureMap default = 3 (kOnOff | kLighting):
9320+ {{#if_feature_bit_enabled "3" "1"}}enabled{{else}}disabled{{/if_feature_bit_enabled}}
9321+ // → "enabled"
9322+ {{#if_feature_bit_enabled "3" "4"}}enabled{{else}}disabled{{/if_feature_bit_enabled}}
9323+ // → "disabled" (kFrequency bit 0x4 is not set)
9324+ ```
9325+ <a name="module_Templating API_ Attribute helpers..cluster_feature_items"></a>
9326+
9327+ ### Templating API: Attribute helpers~cluster\_feature\_items(options) ⇒ <code>Promise.<string></code>
9328+ Block helper that iterates over all fields of the Feature bitmap for a
9329+ cluster identified by its ZCL cluster code, regardless of which bits are
9330+ currently enabled. Use `if_feature_bit_enabled` inside the body to act on
9331+ only those fields whose bit is set in a given FeatureMap value.
9332+
9333+ This is the preferred way to access Feature bitmap fields inside
9334+ `user_cluster_attributes` because `zcl_bitmaps` requires a cluster database
9335+ `id` in context that is not available there. This helper performs the cluster
9336+ lookup by ZCL code (not name) for robustness.
9337+
9338+ Each iteration context exposes:
9339+ - `name` {string} field name as stored in the ZCL database (e.g. `"kOnOff"`)
9340+ - `label` {string} same as `name`
9341+ - `mask` {number} the field's bitmask (e.g. `1`)
9342+
9343+ If the cluster has no bitmap named 'Feature' the body is never rendered.
9344+
9345+ **Kind**: inner method of [<code>Templating API: Attribute helpers</code>](#module_Templating API_ Attribute helpers)
9346+ **Returns**: <code>Promise.<string></code> - Concatenated rendered blocks for each feature field.
9347+ **Given**: <code>string\|number</code> clusterCode - The ZCL cluster code (e.g. `8` for
9348+ LevelControl). Inside `user_cluster_attributes` pass `../code` to
9349+ reference the enclosing `user_clusters` cluster code.
9350+
9351+ | Param | Type | Description |
9352+ | --- | --- | --- |
9353+ | options | <code>\*</code> | Handlebars options object. |
9354+
9355+ **Example**
9356+ ```js
9357+ // List only enabled feature bits for LevelControl (featureMap default = 3):
9358+ {{#if (is_str_equal name "FeatureMap")}}
9359+ {{#cluster_feature_items ../code}}
9360+ {{#if_feature_bit_enabled ../defaultValue mask}}
9361+ FeatureBitmapType::k{{asUpperCamelCase label preserveAcronyms=true}}, // feature bit {{as_hex mask}}
9362+ {{/if_feature_bit_enabled}}
9363+ {{/cluster_feature_items}}
9364+ {{/if}}
9365+ // Emits: FeatureBitmapType::kOnOff, // feature bit 0x1
9366+ // FeatureBitmapType::kLighting, // feature bit 0x2
9367+ // Skips kFrequency (mask 0x4 not set in value 3)
9368+ ```
9369+ **Example**
9370+ ```js
9371+ // List ALL defined feature bits regardless of enabled state:
9372+ {{#cluster_feature_items clusterCode}}
9373+ {{label}}: {{as_hex mask}}
9374+ {{/cluster_feature_items}}
9375+ ```
92399376<a name="module_Templating API_ C formatting helpers"></a>
92409377
92419378## Templating API: C formatting helpers
0 commit comments